@khanacademy/wonder-blocks-data 3.1.2 → 3.1.3
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/components/gql-router.js +1 -1
- package/src/hooks/use-gql.js +3 -8
- package/src/util/gql-types.js +5 -10
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/hooks/use-gql.js
CHANGED
|
@@ -24,7 +24,7 @@ export const useGql = (): (<
|
|
|
24
24
|
TVariables: {...},
|
|
25
25
|
TContext: GqlContext,
|
|
26
26
|
>(
|
|
27
|
-
operation: GqlOperation<
|
|
27
|
+
operation: GqlOperation<TData, TVariables>,
|
|
28
28
|
options?: GqlFetchOptions<TVariables, TContext>,
|
|
29
29
|
) => Promise<?TData>) => {
|
|
30
30
|
// This hook only works if the `GqlRouter` has been used to setup context.
|
|
@@ -41,13 +41,8 @@ export const useGql = (): (<
|
|
|
41
41
|
// in hooks deps without fear of it triggering extra renders.
|
|
42
42
|
const gqlFetch = useMemo(
|
|
43
43
|
() =>
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
TData,
|
|
47
|
-
TVariables: {...},
|
|
48
|
-
TContext: GqlContext,
|
|
49
|
-
>(
|
|
50
|
-
operation: GqlOperation<TType, TData, TVariables>,
|
|
44
|
+
<TData, TVariables: {...}, TContext: GqlContext>(
|
|
45
|
+
operation: GqlOperation<TData, TVariables>,
|
|
51
46
|
options: GqlFetchOptions<TVariables, TContext> = Object.freeze(
|
|
52
47
|
{},
|
|
53
48
|
),
|
package/src/util/gql-types.js
CHANGED
|
@@ -8,7 +8,6 @@ export type GqlOperationType = "mutation" | "query";
|
|
|
8
8
|
* A GraphQL operation.
|
|
9
9
|
*/
|
|
10
10
|
export type GqlOperation<
|
|
11
|
-
TType: GqlOperationType,
|
|
12
11
|
// TData is not used to define a field on this type, but it is used
|
|
13
12
|
// to ensure that calls using this operation will properly return the
|
|
14
13
|
// correct data type.
|
|
@@ -20,13 +19,14 @@ export type GqlOperation<
|
|
|
20
19
|
// eslint-disable-next-line no-unused-vars
|
|
21
20
|
TVariables: {...} = Empty,
|
|
22
21
|
> = {
|
|
23
|
-
type:
|
|
22
|
+
type: GqlOperationType,
|
|
24
23
|
id: string,
|
|
25
24
|
// We allow other things here to be passed along to the fetch function.
|
|
26
25
|
// For example, we might want to pass the full query/mutation definition
|
|
27
26
|
// as a string here to allow that to be sent to an Apollo server that
|
|
28
27
|
// expects it. This is a courtesy to calling code; these additional
|
|
29
28
|
// values are ignored by WB Data, and passed through as-is.
|
|
29
|
+
[key: string]: mixed,
|
|
30
30
|
...
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -37,13 +37,8 @@ export type GqlContext = {|
|
|
|
37
37
|
/**
|
|
38
38
|
* Functions that make fetches of GQL operations.
|
|
39
39
|
*/
|
|
40
|
-
export type GqlFetchFn<
|
|
41
|
-
|
|
42
|
-
TData,
|
|
43
|
-
TVariables: {...},
|
|
44
|
-
TContext: GqlContext,
|
|
45
|
-
> = (
|
|
46
|
-
operation: GqlOperation<TType, TData, TVariables>,
|
|
40
|
+
export type GqlFetchFn<TData, TVariables: {...}, TContext: GqlContext> = (
|
|
41
|
+
operation: GqlOperation<TData, TVariables>,
|
|
47
42
|
variables: ?TVariables,
|
|
48
43
|
context: TContext,
|
|
49
44
|
) => Promise<Response>;
|
|
@@ -52,7 +47,7 @@ export type GqlFetchFn<
|
|
|
52
47
|
* The configuration stored in the GqlRouterContext context.
|
|
53
48
|
*/
|
|
54
49
|
export type GqlRouterConfiguration<TContext: GqlContext> = {|
|
|
55
|
-
fetch: GqlFetchFn<any, any, any
|
|
50
|
+
fetch: GqlFetchFn<any, any, any>,
|
|
56
51
|
defaultContext: TContext,
|
|
57
52
|
|};
|
|
58
53
|
|