Skip to content

Commit 6894666

Browse files
committedApr 14, 2021
fix(merge): fix handling schema definitions with convertExtensions flag
1 parent aa7fa36 commit 6894666

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed
 

‎.changeset/nasty-days-hug.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-tools/load': patch
3+
'@graphql-tools/merge': patch
4+
---
5+
6+
fix(merge): fix handling schema definitions with convertExtensions flag

‎packages/load/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@graphql-tools/utils": "^7.5.0",
30-
"@graphql-tools/merge": "^6.2.9",
30+
"@graphql-tools/merge": "^6.2.11",
3131
"globby": "11.0.3",
3232
"import-from": "3.0.0",
3333
"is-glob": "4.0.1",

‎packages/load/tests/loaders/schema/schema-from-json.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { loadSchema, loadSchemaSync } from '@graphql-tools/load';
22
import { JsonFileLoader } from '@graphql-tools/json-file-loader';
3-
import { isSchema, GraphQLObjectType, GraphQLInterfaceType } from 'graphql';
3+
import { isSchema } from 'graphql';
44
import { runTests, useMonorepo } from '../../../../testing/utils';
55

66
const monorepo = useMonorepo({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import '../../../../testing/to-be-similar-string'
2+
import { loadSchema, loadSchemaSync } from '@graphql-tools/load';
3+
import { printSchemaWithDirectives } from '@graphql-tools/utils';
4+
import { runTests, useMonorepo } from '../../../../testing/utils';
5+
import { printSchema } from 'graphql';
6+
7+
const monorepo = useMonorepo({
8+
dirname: __dirname,
9+
});
10+
describe('schema from string', () => {
11+
12+
monorepo.correctCWD();
13+
14+
runTests({
15+
async: loadSchema,
16+
sync: loadSchemaSync
17+
})(load => {
18+
it('should load schema from string', async () => {
19+
const schemaString = /* GraphQL */`
20+
type Query {
21+
book: String
22+
}
23+
`;
24+
const schema = await load(schemaString, {
25+
loaders: []
26+
});
27+
const printedSchema = printSchema(schema);
28+
expect(printedSchema).toBeSimilarString(schemaString);
29+
});
30+
it('should load schema from string with schema definition', async () => {
31+
const schemaString = /* GraphQL */`
32+
schema {
33+
query: Query
34+
}
35+
36+
type Query {
37+
book: String
38+
}
39+
`;
40+
const schema = await load(schemaString, {
41+
loaders: []
42+
});
43+
const printedSchema = printSchemaWithDirectives(schema);
44+
expect(printedSchema).toBeSimilarString(schemaString);
45+
});
46+
it('should load schema from string with schema definition and convertExtensions flag', async () => {
47+
const schemaString = /* GraphQL */`
48+
schema {
49+
query: Query
50+
}
51+
52+
type Query {
53+
book: String
54+
}
55+
`;
56+
const schema = await load(schemaString, {
57+
loaders: [],
58+
convertExtensions: true
59+
});
60+
const printedSchema = printSchemaWithDirectives(schema);
61+
expect(printedSchema).toBeSimilarString(schemaString);
62+
});
63+
})
64+
})

‎packages/merge/src/typedefs-mergers/schema-def.ts

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export function mergeSchemaDefs(
3131
if (existingNode) {
3232
return {
3333
kind:
34-
config?.convertExtensions ||
3534
node.kind === Kind.SCHEMA_DEFINITION ||
3635
existingNode.kind === Kind.SCHEMA_DEFINITION
3736
? Kind.SCHEMA_DEFINITION

0 commit comments

Comments
 (0)
Please sign in to comment.