naystack 1.5.15 → 1.5.17
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.
|
@@ -123,16 +123,17 @@ function useAuthQuery(query, variables) {
|
|
|
123
123
|
if (token && variables && calledVars !== JSON.stringify(variables)) {
|
|
124
124
|
setCalledVars(JSON.stringify(variables));
|
|
125
125
|
void fetch({
|
|
126
|
-
|
|
126
|
+
// @ts-expect-error -- to allow dynamic props
|
|
127
|
+
variables: { input },
|
|
127
128
|
context: tokenContext(token),
|
|
128
129
|
fetchPolicy: "no-cache"
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
}, [fetch, token, variables, calledVars]);
|
|
132
133
|
const reFetch = (0, import_react.useCallback)(
|
|
133
|
-
(
|
|
134
|
+
(input2) => fetch({
|
|
134
135
|
// @ts-expect-error -- to allow dynamic props
|
|
135
|
-
variables: { input },
|
|
136
|
+
variables: { input: input2 },
|
|
136
137
|
context: tokenContext(token),
|
|
137
138
|
fetchPolicy: "no-cache"
|
|
138
139
|
}),
|
|
@@ -144,9 +145,9 @@ function useAuthMutation(mutation, options) {
|
|
|
144
145
|
const token = (0, import_client2.useToken)();
|
|
145
146
|
const [mutate, result] = (0, import_client.useMutation)(mutation, options);
|
|
146
147
|
const method = (0, import_react.useCallback)(
|
|
147
|
-
(
|
|
148
|
+
(input2) => mutate({
|
|
148
149
|
// @ts-expect-error -- to allow dynamic props
|
|
149
|
-
variables: { input },
|
|
150
|
+
variables: { input: input2 },
|
|
150
151
|
context: tokenContext(token)
|
|
151
152
|
}),
|
|
152
153
|
[token]
|
|
@@ -90,7 +90,7 @@ declare const tokenContext: (token?: string | null) => {
|
|
|
90
90
|
*
|
|
91
91
|
* @category GraphQL
|
|
92
92
|
*/
|
|
93
|
-
declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(input
|
|
93
|
+
declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V["input"]): readonly [(input?: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
|
|
94
94
|
/**
|
|
95
95
|
* Hook to run a GraphQL mutation with the current user's token. Returns a function you call with the mutation input.
|
|
96
96
|
*
|
|
@@ -126,6 +126,6 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
|
|
|
126
126
|
*
|
|
127
127
|
* @category GraphQL
|
|
128
128
|
*/
|
|
129
|
-
declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input
|
|
129
|
+
declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
|
|
130
130
|
|
|
131
131
|
export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
|
package/dist/graphql/client.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ declare const tokenContext: (token?: string | null) => {
|
|
|
90
90
|
*
|
|
91
91
|
* @category GraphQL
|
|
92
92
|
*/
|
|
93
|
-
declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(input
|
|
93
|
+
declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V["input"]): readonly [(input?: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
|
|
94
94
|
/**
|
|
95
95
|
* Hook to run a GraphQL mutation with the current user's token. Returns a function you call with the mutation input.
|
|
96
96
|
*
|
|
@@ -126,6 +126,6 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
|
|
|
126
126
|
*
|
|
127
127
|
* @category GraphQL
|
|
128
128
|
*/
|
|
129
|
-
declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input
|
|
129
|
+
declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
|
|
130
130
|
|
|
131
131
|
export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
|
|
@@ -99,16 +99,17 @@ function useAuthQuery(query, variables) {
|
|
|
99
99
|
if (token && variables && calledVars !== JSON.stringify(variables)) {
|
|
100
100
|
setCalledVars(JSON.stringify(variables));
|
|
101
101
|
void fetch({
|
|
102
|
-
|
|
102
|
+
// @ts-expect-error -- to allow dynamic props
|
|
103
|
+
variables: { input },
|
|
103
104
|
context: tokenContext(token),
|
|
104
105
|
fetchPolicy: "no-cache"
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
}, [fetch, token, variables, calledVars]);
|
|
108
109
|
const reFetch = useCallback(
|
|
109
|
-
(
|
|
110
|
+
(input2) => fetch({
|
|
110
111
|
// @ts-expect-error -- to allow dynamic props
|
|
111
|
-
variables: { input },
|
|
112
|
+
variables: { input: input2 },
|
|
112
113
|
context: tokenContext(token),
|
|
113
114
|
fetchPolicy: "no-cache"
|
|
114
115
|
}),
|
|
@@ -120,9 +121,9 @@ function useAuthMutation(mutation, options) {
|
|
|
120
121
|
const token = useToken();
|
|
121
122
|
const [mutate, result] = useMutation(mutation, options);
|
|
122
123
|
const method = useCallback(
|
|
123
|
-
(
|
|
124
|
+
(input2) => mutate({
|
|
124
125
|
// @ts-expect-error -- to allow dynamic props
|
|
125
|
-
variables: { input },
|
|
126
|
+
variables: { input: input2 },
|
|
126
127
|
context: tokenContext(token)
|
|
127
128
|
}),
|
|
128
129
|
[token]
|
package/dist/graphql/utils.d.mts
CHANGED
|
@@ -6,11 +6,13 @@ import { AuthorizedContext, Context } from './types.mjs';
|
|
|
6
6
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
7
7
|
/** Options for @Arg() (e.g. nullable). */
|
|
8
8
|
type ArgsOptions = Parameters<typeof Arg>[2];
|
|
9
|
-
/**
|
|
9
|
+
/** Recursively applies NormalizeNullUndefined to plain object types, leaves primitives/builtins as-is. */
|
|
10
|
+
type RecurseNNU<T> = T extends (infer U)[] ? RecurseNNU<U>[] : T extends Date | Map<unknown, unknown> | Set<unknown> | Function ? T : T extends object ? NormalizeNullUndefined<T> : T;
|
|
11
|
+
/** Maps nullable keys to optional and normalizes null/undefined, recursively. */
|
|
10
12
|
type NormalizeNullUndefined<T> = {
|
|
11
|
-
[K in keyof T as null extends T[K] ? K : never]?: Exclude<T[K], undefined
|
|
13
|
+
[K in keyof T as null extends T[K] ? K : never]?: RecurseNNU<Exclude<T[K], null | undefined>> | null;
|
|
12
14
|
} & {
|
|
13
|
-
[K in keyof T as null extends T[K] ? never : K]: undefined extends T[K] ? Exclude<T[K], undefined
|
|
15
|
+
[K in keyof T as null extends T[K] ? never : K]: undefined extends T[K] ? RecurseNNU<Exclude<T[K], undefined>> | null : RecurseNNU<T[K]>;
|
|
14
16
|
};
|
|
15
17
|
/** Adds nullable option to Query/Arg options. */
|
|
16
18
|
type NullableOptions<T, X extends boolean> = T & {
|
package/dist/graphql/utils.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ import { AuthorizedContext, Context } from './types.js';
|
|
|
6
6
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
7
7
|
/** Options for @Arg() (e.g. nullable). */
|
|
8
8
|
type ArgsOptions = Parameters<typeof Arg>[2];
|
|
9
|
-
/**
|
|
9
|
+
/** Recursively applies NormalizeNullUndefined to plain object types, leaves primitives/builtins as-is. */
|
|
10
|
+
type RecurseNNU<T> = T extends (infer U)[] ? RecurseNNU<U>[] : T extends Date | Map<unknown, unknown> | Set<unknown> | Function ? T : T extends object ? NormalizeNullUndefined<T> : T;
|
|
11
|
+
/** Maps nullable keys to optional and normalizes null/undefined, recursively. */
|
|
10
12
|
type NormalizeNullUndefined<T> = {
|
|
11
|
-
[K in keyof T as null extends T[K] ? K : never]?: Exclude<T[K], undefined
|
|
13
|
+
[K in keyof T as null extends T[K] ? K : never]?: RecurseNNU<Exclude<T[K], null | undefined>> | null;
|
|
12
14
|
} & {
|
|
13
|
-
[K in keyof T as null extends T[K] ? never : K]: undefined extends T[K] ? Exclude<T[K], undefined
|
|
15
|
+
[K in keyof T as null extends T[K] ? never : K]: undefined extends T[K] ? RecurseNNU<Exclude<T[K], undefined>> | null : RecurseNNU<T[K]>;
|
|
14
16
|
};
|
|
15
17
|
/** Adds nullable option to Query/Arg options. */
|
|
16
18
|
type NullableOptions<T, X extends boolean> = T & {
|