Skip to content

Commit ac77ce9

Browse files
ardatangilgardosh
andauthored
feat(omnigraph/rest): jsonStringify flag to serialize nested query params as JSON (ardatan#7046)
* Changesetr * update documentation * experiment * markdown updates * forward string params * Update snapshots --------- Co-authored-by: Gil Gardosh <[email protected]>
1 parent 0989778 commit ac77ce9

File tree

58 files changed

+235
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+235
-72
lines changed

.changeset/tough-zoos-travel.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
'@graphql-mesh/json-schema': patch
3+
'@omnigraph/json-schema': patch
4+
'@graphql-mesh/transport-rest': patch
5+
---
6+
7+
New option for query string parameters `jsonStringify`;
8+
9+
Now either under the operation or globally, you can set `jsonStringify` to `true` to stringify nested query string parameters as JSON.
10+
11+
```yaml
12+
operations:
13+
- type: Query
14+
field: books
15+
method: GET
16+
path: /books
17+
queryStringOptions:
18+
jsonStringify: true
19+
queryParamArgMap:
20+
page: page
21+
argTypeMap:
22+
page:
23+
type: object
24+
additionalProperties: false
25+
properties:
26+
limit:
27+
type: integer
28+
offset:
29+
type: integer
30+
responseSample:
31+
books:
32+
- title: "Book 1"
33+
- title: "Book 2"
34+
```
35+
36+
Then the URL will be `/books?page={"limit":10,"offset":0}`, as you can see `page` is stringified as JSON.

e2e/auto-type-merging/__snapshots__/auto-type-merging.test.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ directive @httpOperation(
9797
queryParamArgMap: ObjMap
9898
queryStringOptionsByParam: ObjMap
9999
jsonApiFields: Boolean
100+
queryStringOptions: ObjMap
100101
) repeatable on FIELD_DEFINITION
101102
102103
directive @transport(

e2e/federation-mixed/__snapshots__/federation-mixed.test.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ directive @httpOperation(
9999
queryParamArgMap: ObjMap
100100
queryStringOptionsByParam: ObjMap
101101
jsonApiFields: Boolean
102+
queryStringOptions: ObjMap
102103
) repeatable on FIELD_DEFINITION
103104
104105
directive @transport(

e2e/json-schema-subscriptions/__snapshots__/json-schema-subscriptions.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ directive @link(url: String, as: String, for: link__Purpose, import: [link__Impo
2323
2424
directive @example(subgraph: String, value: ObjMap) repeatable on FIELD_DEFINITION | OBJECT | INPUT_OBJECT | ENUM | SCALAR
2525
26-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) repeatable on FIELD_DEFINITION
26+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) repeatable on FIELD_DEFINITION
2727
2828
directive @pubsubOperation(subgraph: String, pubsubTopic: String) repeatable on FIELD_DEFINITION
2929

e2e/openapi-javascript-wiki/__snapshots__/openapi-javascript-wiki.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ directive @resolveRoot(subgraph: String) repeatable on FIELD_DEFINITION
2626
2727
directive @resolveRootField(subgraph: String, field: String) repeatable on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
2828
29-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) repeatable on FIELD_DEFINITION
29+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) repeatable on FIELD_DEFINITION
3030
3131
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) repeatable on SCHEMA
3232

e2e/openapi-subscriptions/__snapshots__/openapi-subscriptions.test.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ directive @httpOperation(
9494
queryParamArgMap: ObjMap
9595
queryStringOptionsByParam: ObjMap
9696
jsonApiFields: Boolean
97+
queryStringOptions: ObjMap
9798
) repeatable on FIELD_DEFINITION
9899
99100
directive @pubsubOperation(subgraph: String, pubsubTopic: String) repeatable on FIELD_DEFINITION

e2e/programmatic-batching/__snapshots__/programmatic-batching.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on
2020
2121
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
2222
23-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) repeatable on FIELD_DEFINITION
23+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) repeatable on FIELD_DEFINITION
2424
2525
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) repeatable on SCHEMA
2626

examples/hello-world-esm/tests/__snapshots__/hello-world.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Hello World should generate correct schema 1`] = `
55
query: Query
66
}
77
8-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
8+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
99
1010
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1111

examples/hello-world/tests/__snapshots__/hello-world.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Hello World should generate correct schema 1`] = `
55
query: Query
66
}
77
8-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
8+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
99
1010
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1111

examples/json-schema-covid/tests/__snapshots__/json-schema-covid.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`JSON Schema Covid should generate correct schema: json-schema-covid-sch
44
"""""""
55
directive @cacheControl(maxAge: Int, scope: CacheControlScope) on FIELD_DEFINITION | INTERFACE | OBJECT
66
7-
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
7+
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptions: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
88
99
directive @resolveTo(additionalArgs: ResolveToSourceArgs, filterBy: String, keyField: String, keysArg: String, pubsubTopic: String, requiredSelectionSet: String, result: String, resultType: String, sourceArgs: ResolveToSourceArgs, sourceFieldName: String!, sourceName: String!, sourceSelectionSet: String, sourceTypeName: String!) on FIELD_DEFINITION
1010

examples/json-schema-example/tests/__snapshots__/json-schema-example.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ directive @enum(subgraph: String, value: String) on ENUM_VALUE
1010
1111
directive @example(subgraph: String, value: ObjMap) repeatable on FIELD_DEFINITION | OBJECT | INPUT_OBJECT | ENUM | SCALAR
1212
13-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HttpMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
13+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HttpMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1414
1515
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1616

examples/json-schema-fhir/tests/__snapshots__/fhir.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ directive @example(subgraph: String, value: ObjMap) repeatable on FIELD_DEFINITI
1313

1414
directive @regexp(subgraph: String, pattern: String) on SCALAR
1515

16-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
16+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1717

1818
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1919

examples/json-schema-subscriptions/tests/__snapshots__/json-schema-subscriptions.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`JSON Schema Subscriptions should generate correct schema 1`] = `
99
1010
directive @example(subgraph: String, value: ObjMap) repeatable on FIELD_DEFINITION | OBJECT | INPUT_OBJECT | ENUM | SCALAR
1111
12-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
12+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1313
1414
directive @pubsubOperation(subgraph: String, pubsubTopic: String) on FIELD_DEFINITION
1515

examples/openapi-javascript-wiki/tests/__snapshots__/javascript-wiki.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ directive @enum(subgraph: String, value: String) on ENUM_VALUE
1414
1515
directive @resolveRootField(subgraph: String, field: String) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
1616
17-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
17+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1818
1919
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
2020

examples/openapi-location-weather/tests/__snapshots__/location-weather.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Location Weather should generate correct schema: location-weather-schema 1`] = `
44
"directive @enum(subgraph: String, value: String) on ENUM_VALUE
55
6-
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
6+
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptions: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
77
88
directive @resolveTo(additionalArgs: ResolveToSourceArgs, filterBy: String, keyField: String, keysArg: String, pubsubTopic: String, requiredSelectionSet: String, result: String, resultType: String, sourceArgs: ResolveToSourceArgs, sourceFieldName: String!, sourceName: String!, sourceSelectionSet: String, sourceTypeName: String!) on FIELD_DEFINITION
99

examples/programmatic-batching/tests/__snapshots__/programmatic-batching.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`Batching Example should generate correct schema 1`] = `
66
mutation: Mutation
77
}
88
9-
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
9+
directive @httpOperation(httpMethod: HTTPMethod, isBinary: Boolean, jsonApiFields: Boolean, operationSpecificHeaders: [[String]], path: String, queryParamArgMap: ObjMap, queryStringOptions: ObjMap, queryStringOptionsByParam: ObjMap, requestBaseBody: ObjMap, subgraph: String) on FIELD_DEFINITION
1010
1111
directive @transport(headers: [[String]], kind: String, location: String, queryParams: [[String]], queryStringOptions: ObjMap, subgraph: String) on SCHEMA
1212

examples/v1-next/integrations/fastify/supergraph.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ directive @httpOperation(
7474
queryParamArgMap: ObjMap
7575
queryStringOptionsByParam: ObjMap
7676
jsonApiFields: Boolean
77+
queryStringOptions: ObjMap
7778
) repeatable on FIELD_DEFINITION
7879

7980
directive @transport(

packages/legacy/handlers/json-schema/yaml-config.graphql

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ type QueryStringOptions @md {
2525
(default: false)
2626
"""
2727
commaRoundTrip: Boolean
28+
"""
29+
Stringify the nested objects as JSON
30+
(default: false)
31+
"""
32+
jsonStringify: Boolean
2833
}
2934

3035
enum QueryStringArrayFormat {

packages/legacy/types/src/config-schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,10 @@
10241024
"commaRoundTrip": {
10251025
"type": "boolean",
10261026
"description": "Even if there is a single item in an array, this option treats them as arrays\n(default: false)"
1027+
},
1028+
"jsonStringify": {
1029+
"type": "boolean",
1030+
"description": "Stringify the nested objects as JSON\n(default: false)"
10271031
}
10281032
}
10291033
},

packages/legacy/types/src/config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ export interface QueryStringOptions {
538538
* (default: false)
539539
*/
540540
commaRoundTrip?: boolean;
541+
/**
542+
* Stringify the nested objects as JSON
543+
* (default: false)
544+
*/
545+
jsonStringify?: boolean;
541546
}
542547
export interface MongooseHandler {
543548
connectionString?: string;

packages/loaders/json-schema/src/addExecutionLogicToComposer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ${operationConfig.description || ''}
119119
queryParamArgMap: operationConfig.queryParamArgMap,
120120
queryStringOptionsByParam: operationConfig.queryStringOptionsByParam,
121121
jsonApiFields: operationConfig.jsonApiFields,
122+
queryStringOptions: 'queryStringOptions' in operationConfig ? operationConfig.queryStringOptions : undefined,
122123
}),
123124
),
124125
});

packages/loaders/json-schema/src/directives.ts

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export const HTTPOperationDirective = new GraphQLDirective({
152152
jsonApiFields: {
153153
type: GraphQLBoolean,
154154
},
155+
queryStringOptions: {
156+
type: ObjMapScalar,
157+
},
155158
},
156159
});
157160

packages/loaders/json-schema/src/types.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface JSONSchemaLoaderOptions extends BaseLoaderOptions {
1818
fetch?: MeshFetch;
1919
ignoreErrorResponses?: boolean;
2020
queryParams?: Record<string, string | number | boolean>;
21-
queryStringOptions?: IStringifyOptions;
21+
queryStringOptions?: IStringifyOptions & { jsonStringify?: boolean };
2222
handlerName?: string;
2323
bundle?: boolean;
2424
getScalarForFormat?: (format: string) => GraphQLScalarType | void;
@@ -75,7 +75,10 @@ export type JSONSchemaHTTPBaseOperationConfig = JSONSchemaBaseOperationConfig &
7575

7676
headers?: Record<string, string>;
7777
queryParamArgMap?: Record<string, string>;
78-
queryStringOptionsByParam?: Record<string, IStringifyOptions & { destructObject?: boolean }>;
78+
queryStringOptionsByParam?: Record<
79+
string,
80+
IStringifyOptions & { destructObject?: boolean; jsonStringify?: boolean }
81+
>;
7982
queryParamsSample?: any;
8083

8184
jsonApiFields?: boolean;

packages/loaders/json-schema/test/__snapshots__/query-params.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Query Params queryParamsSample with invalid param names: queryParamsSam
55
query: Query
66
}
77
8-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
8+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
99
1010
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1111

packages/loaders/json-schema/test/execution.test.ts

+68
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,74 @@ describe('Execution', () => {
346346
},
347347
});
348348
});
349+
it('jsonStringify', async () => {
350+
const schema = await loadGraphQLSchemaFromJSONSchemas('test', {
351+
async fetch(info: RequestInfo, init?: RequestInit) {
352+
let request: Request;
353+
if (typeof info !== 'object') {
354+
request = new Request(info, init);
355+
} else {
356+
request = info;
357+
}
358+
return new Response(
359+
JSON.stringify({
360+
url: request.url,
361+
}),
362+
{
363+
headers: {
364+
'Content-Type': 'application/json',
365+
},
366+
},
367+
);
368+
},
369+
endpoint: 'http://localhost:3000',
370+
queryStringOptions: {
371+
jsonStringify: true,
372+
},
373+
operations: [
374+
{
375+
type: OperationTypeNode.QUERY,
376+
field: 'test',
377+
method: 'GET',
378+
path: '/test',
379+
queryParamArgMap: {
380+
foo: 'foo',
381+
},
382+
argTypeMap: {
383+
foo: {
384+
type: 'object',
385+
properties: {
386+
bar: {
387+
type: 'string',
388+
},
389+
},
390+
},
391+
},
392+
responseSample: {
393+
url: 'http://localhost:3000/test?foo={"bar":"baz"}',
394+
},
395+
},
396+
],
397+
});
398+
const query = /* GraphQL */ `
399+
query Test {
400+
test(foo: { bar: "baz" }) {
401+
url
402+
}
403+
}
404+
`;
405+
const result = await execute({
406+
schema,
407+
document: parse(query),
408+
});
409+
expect(result).toEqual({
410+
data: {
411+
test: {
412+
url: `http://localhost:3000/test?foo=${encodeURIComponent('{"bar":"baz"}')}`,
413+
},
414+
},
415+
});
416+
});
349417
});
350418
describe('Sanization', () => {
351419
it('should recover escaped input field names before preparing the request for GET', async () => {

packages/loaders/openapi/tests/__snapshots__/additionalProperties.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`additionalProperties should generate the schema correctly: schema 1`] =
77
88
directive @dictionary(subgraph: String) on FIELD_DEFINITION
99
10-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
10+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1111
1212
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1313

packages/loaders/openapi/tests/__snapshots__/allof-properties.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ directive @discriminator(subgraph: String, field: String, mapping: ObjMap) on IN
1010
1111
directive @length(subgraph: String, min: Int, max: Int) on SCALAR
1212
13-
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean) on FIELD_DEFINITION
13+
directive @httpOperation(subgraph: String, path: String, operationSpecificHeaders: [[String]], httpMethod: HTTPMethod, isBinary: Boolean, requestBaseBody: ObjMap, queryParamArgMap: ObjMap, queryStringOptionsByParam: ObjMap, jsonApiFields: Boolean, queryStringOptions: ObjMap) on FIELD_DEFINITION
1414
1515
directive @transport(subgraph: String, kind: String, location: String, headers: [[String]], queryStringOptions: ObjMap, queryParams: [[String]]) on SCHEMA
1616

0 commit comments

Comments
 (0)