@graphql-codegen/typescript-jit-sdk 1.0.0-alpha-68dda50ed.0 → 1.0.0-alpha-aa5704d35.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.
Files changed (3) hide show
  1. package/index.js +3 -3
  2. package/index.mjs +3 -3
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -61,7 +61,7 @@ class JitSdkVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
61
61
  const returnType = o.operationType === 'Subscription'
62
62
  ? `AsyncIterableIterator<${o.operationResultType}> | ${o.operationResultType}`
63
63
  : o.operationResultType;
64
- sdkMethods.push(visitorPluginCommon.indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context?: C, root?: R): Promise<${returnType}> {
64
+ sdkMethods.push(visitorPluginCommon.indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context = globalContext, root = globalRoot): Promise<${returnType}> {
65
65
  const result = await ${compiledQueryVariableName}.${methodName}(root, context, variables);
66
66
  return ${handlerName}(result, '${operationName}');
67
67
  }`, 2));
@@ -79,13 +79,13 @@ class JitSdkVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
79
79
  }
80
80
  return result.data as T;
81
81
  }
82
- export function getJitSdk<C = any, R = any>(schema: GraphQLSchema) {
82
+ export function getSdk<C = any, R = any>(schema: GraphQLSchema, globalContext?: C, globalRoot?: R) {
83
83
  ${compiledQueries.join('\n')}
84
84
  return {
85
85
  ${sdkMethods.join(',\n')}
86
86
  };
87
87
  }
88
- export type JitSdk = ReturnType<typeof getJitSdk>;`;
88
+ export type Sdk = ReturnType<typeof getSdk>;`;
89
89
  }
90
90
  }
91
91
 
package/index.mjs CHANGED
@@ -55,7 +55,7 @@ class JitSdkVisitor extends ClientSideBaseVisitor {
55
55
  const returnType = o.operationType === 'Subscription'
56
56
  ? `AsyncIterableIterator<${o.operationResultType}> | ${o.operationResultType}`
57
57
  : o.operationResultType;
58
- sdkMethods.push(indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context?: C, root?: R): Promise<${returnType}> {
58
+ sdkMethods.push(indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context = globalContext, root = globalRoot): Promise<${returnType}> {
59
59
  const result = await ${compiledQueryVariableName}.${methodName}(root, context, variables);
60
60
  return ${handlerName}(result, '${operationName}');
61
61
  }`, 2));
@@ -73,13 +73,13 @@ class JitSdkVisitor extends ClientSideBaseVisitor {
73
73
  }
74
74
  return result.data as T;
75
75
  }
76
- export function getJitSdk<C = any, R = any>(schema: GraphQLSchema) {
76
+ export function getSdk<C = any, R = any>(schema: GraphQLSchema, globalContext?: C, globalRoot?: R) {
77
77
  ${compiledQueries.join('\n')}
78
78
  return {
79
79
  ${sdkMethods.join(',\n')}
80
80
  };
81
81
  }
82
- export type JitSdk = ReturnType<typeof getJitSdk>;`;
82
+ export type Sdk = ReturnType<typeof getSdk>;`;
83
83
  }
84
84
  }
85
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-jit-sdk",
3
- "version": "1.0.0-alpha-68dda50ed.0",
3
+ "version": "1.0.0-alpha-aa5704d35.0",
4
4
  "description": "GraphQL Code Generator plugin for generating a ready-to-use SDK that uses GraphQL JIT",
5
5
  "peerDependencies": {
6
6
  "@graphql-tools/utils": "8.2.4",