Skip to content

Commit 669db69

Browse files
committed
5.4.1 generation of SDK and clients possible due to crucial change in thunderOptions position for scalars argument
1 parent e08907f commit 669db69

File tree

6 files changed

+50
-32
lines changed

6 files changed

+50
-32
lines changed

examples/typescript-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-node",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "",
55
"private": true,
66
"main": "index.js",

packages/graphql-zeus-core/TreeToTS/functions/generated.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export const InternalsBuildQuery = ({
118118
};
119119
120120
export const Thunder =
121-
(fn: FetchFunction) =>
122-
<O extends keyof typeof Ops, SCLR extends ScalarDefinition, R extends keyof ValueTypes = GenericOperation<O>>(
121+
<SCLR extends ScalarDefinition>(fn: FetchFunction, thunderGraphQLOptions?: ThunderGraphQLOptions<SCLR>) =>
122+
<O extends keyof typeof Ops, R extends keyof ValueTypes = GenericOperation<O>>(
123123
operation: O,
124124
graphqlOptions?: ThunderGraphQLOptions<SCLR>,
125125
) =>
@@ -128,32 +128,37 @@ export const Thunder =
128128
[P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never;
129129
},
130130
ops?: OperationOptions & { variables?: Record<string, unknown> },
131-
) =>
132-
fn(
131+
) => {
132+
const options = {
133+
...thunderGraphQLOptions,
134+
...graphqlOptions,
135+
};
136+
return fn(
133137
Zeus(operation, o, {
134138
operationOptions: ops,
135-
scalars: graphqlOptions?.scalars,
139+
scalars: options?.scalars,
136140
}),
137141
ops?.variables,
138142
).then((data) => {
139-
if (graphqlOptions?.scalars) {
143+
if (options?.scalars) {
140144
return decodeScalarsInResponse({
141145
response: data,
142146
initialOp: operation,
143147
initialZeusQuery: o as VType,
144148
returns: ReturnTypes,
145-
scalars: graphqlOptions.scalars,
149+
scalars: options.scalars,
146150
ops: Ops,
147151
});
148152
}
149153
return data;
150154
}) as Promise<InputType<GraphQLTypes[R], Z, SCLR>>;
155+
};
151156
152157
export const Chain = (...options: chainOptions) => Thunder(apiFetch(options));
153158
154159
export const SubscriptionThunder =
155-
(fn: SubscriptionFunction) =>
156-
<O extends keyof typeof Ops, SCLR extends ScalarDefinition, R extends keyof ValueTypes = GenericOperation<O>>(
160+
<SCLR extends ScalarDefinition>(fn: SubscriptionFunction, thunderGraphQLOptions?: ThunderGraphQLOptions<SCLR>) =>
161+
<O extends keyof typeof Ops, R extends keyof ValueTypes = GenericOperation<O>>(
157162
operation: O,
158163
graphqlOptions?: ThunderGraphQLOptions<SCLR>,
159164
) =>
@@ -163,24 +168,28 @@ export const SubscriptionThunder =
163168
},
164169
ops?: OperationOptions & { variables?: ExtractVariables<Z> },
165170
) => {
171+
const options = {
172+
...thunderGraphQLOptions,
173+
...graphqlOptions,
174+
};
166175
const returnedFunction = fn(
167176
Zeus(operation, o, {
168177
operationOptions: ops,
169-
scalars: graphqlOptions?.scalars,
178+
scalars: options?.scalars,
170179
}),
171180
) as SubscriptionToGraphQL<Z, GraphQLTypes[R], SCLR>;
172-
if (returnedFunction?.on && graphqlOptions?.scalars) {
181+
if (returnedFunction?.on && options?.scalars) {
173182
const wrapped = returnedFunction.on;
174183
returnedFunction.on = (fnToCall: (args: InputType<GraphQLTypes[R], Z, SCLR>) => void) =>
175184
wrapped((data: InputType<GraphQLTypes[R], Z, SCLR>) => {
176-
if (graphqlOptions?.scalars) {
185+
if (options?.scalars) {
177186
return fnToCall(
178187
decodeScalarsInResponse({
179188
response: data,
180189
initialOp: operation,
181190
initialZeusQuery: o as VType,
182191
returns: ReturnTypes,
183-
scalars: graphqlOptions.scalars,
192+
scalars: options.scalars,
184193
ops: Ops,
185194
}),
186195
);

packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { InputType, ScalarDefinition, SelectionFunction, SubscriptionToGraphQL }
2525
import { ExtractVariables } from '@/TreeToTS/functions/new/variableExtract';
2626

2727
export const Thunder =
28-
(fn: FetchFunction) =>
29-
<O extends keyof typeof Ops, SCLR extends ScalarDefinition, R extends keyof ValueTypes = GenericOperation<O>>(
28+
<SCLR extends ScalarDefinition>(fn: FetchFunction, thunderGraphQLOptions?: ThunderGraphQLOptions<SCLR>) =>
29+
<O extends keyof typeof Ops, R extends keyof ValueTypes = GenericOperation<O>>(
3030
operation: O,
3131
graphqlOptions?: ThunderGraphQLOptions<SCLR>,
3232
) =>
@@ -35,32 +35,37 @@ export const Thunder =
3535
[P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never;
3636
},
3737
ops?: OperationOptions & { variables?: Record<string, unknown> },
38-
) =>
39-
fn(
38+
) => {
39+
const options = {
40+
...thunderGraphQLOptions,
41+
...graphqlOptions,
42+
};
43+
return fn(
4044
Zeus(operation, o, {
4145
operationOptions: ops,
42-
scalars: graphqlOptions?.scalars,
46+
scalars: options?.scalars,
4347
}),
4448
ops?.variables,
4549
).then((data) => {
46-
if (graphqlOptions?.scalars) {
50+
if (options?.scalars) {
4751
return decodeScalarsInResponse({
4852
response: data,
4953
initialOp: operation,
5054
initialZeusQuery: o as VType,
5155
returns: ReturnTypes,
52-
scalars: graphqlOptions.scalars,
56+
scalars: options.scalars,
5357
ops: Ops,
5458
});
5559
}
5660
return data;
5761
}) as Promise<InputType<GraphQLTypes[R], Z, SCLR>>;
62+
};
5863

5964
export const Chain = (...options: chainOptions) => Thunder(apiFetch(options));
6065

6166
export const SubscriptionThunder =
62-
(fn: SubscriptionFunction) =>
63-
<O extends keyof typeof Ops, SCLR extends ScalarDefinition, R extends keyof ValueTypes = GenericOperation<O>>(
67+
<SCLR extends ScalarDefinition>(fn: SubscriptionFunction, thunderGraphQLOptions?: ThunderGraphQLOptions<SCLR>) =>
68+
<O extends keyof typeof Ops, R extends keyof ValueTypes = GenericOperation<O>>(
6469
operation: O,
6570
graphqlOptions?: ThunderGraphQLOptions<SCLR>,
6671
) =>
@@ -70,24 +75,28 @@ export const SubscriptionThunder =
7075
},
7176
ops?: OperationOptions & { variables?: ExtractVariables<Z> },
7277
) => {
78+
const options = {
79+
...thunderGraphQLOptions,
80+
...graphqlOptions,
81+
};
7382
const returnedFunction = fn(
7483
Zeus(operation, o, {
7584
operationOptions: ops,
76-
scalars: graphqlOptions?.scalars,
85+
scalars: options?.scalars,
7786
}),
7887
) as SubscriptionToGraphQL<Z, GraphQLTypes[R], SCLR>;
79-
if (returnedFunction?.on && graphqlOptions?.scalars) {
88+
if (returnedFunction?.on && options?.scalars) {
8089
const wrapped = returnedFunction.on;
8190
returnedFunction.on = (fnToCall: (args: InputType<GraphQLTypes[R], Z, SCLR>) => void) =>
8291
wrapped((data: InputType<GraphQLTypes[R], Z, SCLR>) => {
83-
if (graphqlOptions?.scalars) {
92+
if (options?.scalars) {
8493
return fnToCall(
8594
decodeScalarsInResponse({
8695
response: data,
8796
initialOp: operation,
8897
initialZeusQuery: o as VType,
8998
returns: ReturnTypes,
90-
scalars: graphqlOptions.scalars,
99+
scalars: options.scalars,
91100
ops: Ops,
92101
}),
93102
);

packages/graphql-zeus-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus-core",
3-
"version": "5.4.0",
3+
"version": "5.4.1",
44
"private": false,
55
"main": "./lib/index.js",
66
"author": "GraphQL Editor, Artur Czemiel",

packages/graphql-zeus-jsonschema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus-jsonschema",
3-
"version": "5.4.0",
3+
"version": "5.4.1",
44
"private": false,
55
"main": "./lib/index.js",
66
"author": "GraphQL Editor, Artur Czemiel",

packages/graphql-zeus/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus",
3-
"version": "5.4.0",
3+
"version": "5.4.1",
44
"private": false,
55
"scripts": {
66
"start": "ttsc --watch",
@@ -26,8 +26,8 @@
2626
"dependencies": {
2727
"config-maker": "^0.0.2",
2828
"cross-fetch": "^3.0.4",
29-
"graphql-zeus-core": "^5.4.0",
30-
"graphql-zeus-jsonschema": "^5.4.0",
29+
"graphql-zeus-core": "^5.4.1",
30+
"graphql-zeus-jsonschema": "^5.4.1",
3131
"yargs": "^16.1.1"
3232
}
3333
}

0 commit comments

Comments
 (0)