@graphql-codegen/typescript-jit-sdk 1.1.1 → 1.2.0-alpha-8e004ddb5.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/index.js +10 -4
- package/index.mjs +10 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -66,8 +66,14 @@ if(!(isCompiledQuery(${compiledQueryVariableName}))) {
|
|
|
66
66
|
if (o.operationType === 'Subscription') {
|
|
67
67
|
hasSubscription = true;
|
|
68
68
|
}
|
|
69
|
-
sdkMethods.push(visitorPluginCommon.indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context
|
|
70
|
-
const result = await ${compiledQueryVariableName}.${methodName}(
|
|
69
|
+
sdkMethods.push(visitorPluginCommon.indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context?: TOperationContext, root?: TOperationRoot): Promise<${returnType}> {
|
|
70
|
+
const result = await ${compiledQueryVariableName}.${methodName}({
|
|
71
|
+
...globalRoot,
|
|
72
|
+
...root
|
|
73
|
+
}, {
|
|
74
|
+
...globalContext,
|
|
75
|
+
...context
|
|
76
|
+
}, variables);
|
|
71
77
|
return ${handlerName}(result, '${operationName}');
|
|
72
78
|
}`, 2));
|
|
73
79
|
}
|
|
@@ -85,9 +91,9 @@ if(!(isCompiledQuery(${compiledQueryVariableName}))) {
|
|
|
85
91
|
const originalErrors = result.errors.map(error => error.originalError|| error);
|
|
86
92
|
throw new AggregateError(originalErrors, \`Failed to execute \${operationName}: \\n\\t\${originalErrors.join('\\n\\t')}\`);
|
|
87
93
|
}
|
|
88
|
-
return result.data as T;
|
|
94
|
+
return result.data as unknown as T;
|
|
89
95
|
}
|
|
90
|
-
export function getSdk<
|
|
96
|
+
export function getSdk<TGlobalContext = any, TGlobalRoot = any, TOperationContext = any, TOperationRoot = any>(schema: GraphQLSchema, globalContext?: TGlobalContext, globalRoot?: TGlobalRoot) {
|
|
91
97
|
${compiledQueries.join('\n\n')}
|
|
92
98
|
|
|
93
99
|
return {
|
package/index.mjs
CHANGED
|
@@ -60,8 +60,14 @@ if(!(isCompiledQuery(${compiledQueryVariableName}))) {
|
|
|
60
60
|
if (o.operationType === 'Subscription') {
|
|
61
61
|
hasSubscription = true;
|
|
62
62
|
}
|
|
63
|
-
sdkMethods.push(indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context
|
|
64
|
-
const result = await ${compiledQueryVariableName}.${methodName}(
|
|
63
|
+
sdkMethods.push(indentMultiline(`async ${operationName}(variables${optionalVariables ? '?' : ''}: ${o.operationVariablesTypes}, context?: TOperationContext, root?: TOperationRoot): Promise<${returnType}> {
|
|
64
|
+
const result = await ${compiledQueryVariableName}.${methodName}({
|
|
65
|
+
...globalRoot,
|
|
66
|
+
...root
|
|
67
|
+
}, {
|
|
68
|
+
...globalContext,
|
|
69
|
+
...context
|
|
70
|
+
}, variables);
|
|
65
71
|
return ${handlerName}(result, '${operationName}');
|
|
66
72
|
}`, 2));
|
|
67
73
|
}
|
|
@@ -79,9 +85,9 @@ if(!(isCompiledQuery(${compiledQueryVariableName}))) {
|
|
|
79
85
|
const originalErrors = result.errors.map(error => error.originalError|| error);
|
|
80
86
|
throw new AggregateError(originalErrors, \`Failed to execute \${operationName}: \\n\\t\${originalErrors.join('\\n\\t')}\`);
|
|
81
87
|
}
|
|
82
|
-
return result.data as T;
|
|
88
|
+
return result.data as unknown as T;
|
|
83
89
|
}
|
|
84
|
-
export function getSdk<
|
|
90
|
+
export function getSdk<TGlobalContext = any, TGlobalRoot = any, TOperationContext = any, TOperationRoot = any>(schema: GraphQLSchema, globalContext?: TGlobalContext, globalRoot?: TGlobalRoot) {
|
|
85
91
|
${compiledQueries.join('\n\n')}
|
|
86
92
|
|
|
87
93
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-jit-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha-8e004ddb5.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",
|