@mearie/react 0.0.1-next.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,10 +21,12 @@ First, create a client and wrap your app with the provider:
|
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
23
|
// src/App.tsx
|
|
24
|
-
import { createClient,
|
|
24
|
+
import { createClient, httpExchange, cacheExchange, dedupExchange, ClientProvider } from '@mearie/react';
|
|
25
|
+
import { schema } from '$mearie';
|
|
25
26
|
|
|
26
27
|
const client = createClient({
|
|
27
|
-
|
|
28
|
+
schema,
|
|
29
|
+
exchanges: [dedupExchange(), cacheExchange(), httpExchange({ url: 'https://api.example.com/graphql' })],
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
function App() {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { AggregatedError, Artifact, Client, DataOf, FragmentOptions, FragmentRefs, MutationOptions, QueryOptions, SubscriptionOptions, VariablesOf } from "@mearie/core";
|
|
1
|
+
import { AggregatedError, Artifact, Client, DataOf, FragmentOptions, FragmentRefs, MutationOptions, QueryOptions, SchemaMeta, SubscriptionOptions, VariablesOf } from "@mearie/core";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
export * from "@mearie/core";
|
|
4
4
|
|
|
5
5
|
//#region src/client-provider.d.ts
|
|
6
|
-
type ClientProviderProps = {
|
|
7
|
-
client: Client
|
|
6
|
+
type ClientProviderProps<TMeta extends SchemaMeta = SchemaMeta> = {
|
|
7
|
+
client: Client<TMeta>;
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
};
|
|
10
|
-
declare const ClientProvider: ({
|
|
10
|
+
declare const ClientProvider: <TMeta extends SchemaMeta = SchemaMeta>({
|
|
11
11
|
client,
|
|
12
12
|
children
|
|
13
|
-
}: ClientProviderProps) => ReactNode;
|
|
14
|
-
declare const useClient: () => Client
|
|
13
|
+
}: ClientProviderProps<TMeta>) => ReactNode;
|
|
14
|
+
declare const useClient: <TMeta extends SchemaMeta = SchemaMeta>() => Client<TMeta>;
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/use-query.d.ts
|
|
17
17
|
type Query<T extends Artifact<'query'>> = {
|
|
@@ -33,7 +33,7 @@ type Query<T extends Artifact<'query'>> = {
|
|
|
33
33
|
type UseQueryOptions = QueryOptions & {
|
|
34
34
|
skip?: boolean;
|
|
35
35
|
};
|
|
36
|
-
declare const useQuery: <T extends Artifact<"query">>(query: T, ...[variables, options]: VariablesOf<T> extends
|
|
36
|
+
declare const useQuery: <T extends Artifact<"query">>(query: T, ...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseQueryOptions?] : [VariablesOf<T>, UseQueryOptions?]) => Query<T>;
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/use-subscription.d.ts
|
|
39
39
|
type Subscription<T extends Artifact<'subscription'>> = {
|
|
@@ -54,7 +54,7 @@ type UseSubscriptionOptions<T extends Artifact<'subscription'>> = SubscriptionOp
|
|
|
54
54
|
onData?: (data: DataOf<T>) => void;
|
|
55
55
|
onError?: (error: AggregatedError) => void;
|
|
56
56
|
};
|
|
57
|
-
declare const useSubscription: <T extends Artifact<"subscription">>(subscription: T, ...[variables, options]: VariablesOf<T> extends
|
|
57
|
+
declare const useSubscription: <T extends Artifact<"subscription">>(subscription: T, ...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseSubscriptionOptions<T>?] : [VariablesOf<T>, UseSubscriptionOptions<T>?]) => Subscription<T>;
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/use-mutation.d.ts
|
|
60
60
|
type MutationResult<T extends Artifact<'mutation'>> = {
|
|
@@ -71,7 +71,7 @@ type MutationResult<T extends Artifact<'mutation'>> = {
|
|
|
71
71
|
error: AggregatedError;
|
|
72
72
|
};
|
|
73
73
|
type UseMutationOptions = MutationOptions;
|
|
74
|
-
type Mutation<T extends Artifact<'mutation'>> = [(...[variables, options]: VariablesOf<T> extends
|
|
74
|
+
type Mutation<T extends Artifact<'mutation'>> = [(...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseMutationOptions?] : [VariablesOf<T>, UseMutationOptions?]) => Promise<DataOf<T>>, MutationResult<T>];
|
|
75
75
|
declare const useMutation: <T extends Artifact<"mutation">>(mutation: T) => Mutation<T>;
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/use-fragment.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { AggregatedError, Artifact, Client, DataOf, FragmentOptions, FragmentRefs, MutationOptions, QueryOptions, SubscriptionOptions, VariablesOf } from "@mearie/core";
|
|
1
|
+
import { AggregatedError, Artifact, Client, DataOf, FragmentOptions, FragmentRefs, MutationOptions, QueryOptions, SchemaMeta, SubscriptionOptions, VariablesOf } from "@mearie/core";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
export * from "@mearie/core";
|
|
4
4
|
|
|
5
5
|
//#region src/client-provider.d.ts
|
|
6
|
-
type ClientProviderProps = {
|
|
7
|
-
client: Client
|
|
6
|
+
type ClientProviderProps<TMeta extends SchemaMeta = SchemaMeta> = {
|
|
7
|
+
client: Client<TMeta>;
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
};
|
|
10
|
-
declare const ClientProvider: ({
|
|
10
|
+
declare const ClientProvider: <TMeta extends SchemaMeta = SchemaMeta>({
|
|
11
11
|
client,
|
|
12
12
|
children
|
|
13
|
-
}: ClientProviderProps) => ReactNode;
|
|
14
|
-
declare const useClient: () => Client
|
|
13
|
+
}: ClientProviderProps<TMeta>) => ReactNode;
|
|
14
|
+
declare const useClient: <TMeta extends SchemaMeta = SchemaMeta>() => Client<TMeta>;
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/use-query.d.ts
|
|
17
17
|
type Query<T extends Artifact<'query'>> = {
|
|
@@ -33,7 +33,7 @@ type Query<T extends Artifact<'query'>> = {
|
|
|
33
33
|
type UseQueryOptions = QueryOptions & {
|
|
34
34
|
skip?: boolean;
|
|
35
35
|
};
|
|
36
|
-
declare const useQuery: <T extends Artifact<"query">>(query: T, ...[variables, options]: VariablesOf<T> extends
|
|
36
|
+
declare const useQuery: <T extends Artifact<"query">>(query: T, ...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseQueryOptions?] : [VariablesOf<T>, UseQueryOptions?]) => Query<T>;
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/use-subscription.d.ts
|
|
39
39
|
type Subscription<T extends Artifact<'subscription'>> = {
|
|
@@ -54,7 +54,7 @@ type UseSubscriptionOptions<T extends Artifact<'subscription'>> = SubscriptionOp
|
|
|
54
54
|
onData?: (data: DataOf<T>) => void;
|
|
55
55
|
onError?: (error: AggregatedError) => void;
|
|
56
56
|
};
|
|
57
|
-
declare const useSubscription: <T extends Artifact<"subscription">>(subscription: T, ...[variables, options]: VariablesOf<T> extends
|
|
57
|
+
declare const useSubscription: <T extends Artifact<"subscription">>(subscription: T, ...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseSubscriptionOptions<T>?] : [VariablesOf<T>, UseSubscriptionOptions<T>?]) => Subscription<T>;
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/use-mutation.d.ts
|
|
60
60
|
type MutationResult<T extends Artifact<'mutation'>> = {
|
|
@@ -71,7 +71,7 @@ type MutationResult<T extends Artifact<'mutation'>> = {
|
|
|
71
71
|
error: AggregatedError;
|
|
72
72
|
};
|
|
73
73
|
type UseMutationOptions = MutationOptions;
|
|
74
|
-
type Mutation<T extends Artifact<'mutation'>> = [(...[variables, options]: VariablesOf<T> extends
|
|
74
|
+
type Mutation<T extends Artifact<'mutation'>> = [(...[variables, options]: VariablesOf<T> extends Record<string, never> ? [undefined?, UseMutationOptions?] : [VariablesOf<T>, UseMutationOptions?]) => Promise<DataOf<T>>, MutationResult<T>];
|
|
75
75
|
declare const useMutation: <T extends Artifact<"mutation">>(mutation: T) => Mutation<T>;
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/use-fragment.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearie/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Type-safe, zero-overhead GraphQL client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"README.md"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@mearie/core": "0.
|
|
43
|
+
"@mearie/core": "0.1.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/react": "^19.2.2",
|