Skip to content

Commit 2fe123a

Browse files
authored
Revert "fix(utils/astFromSchema): support GraphQLSchema instances without operation types defined" (#7683)
* Revert "fix(utils/astFromSchema): support `GraphQLSchema` instances without o…" This reverts commit dddc5f6. * Changeset
1 parent 631cee3 commit 2fe123a

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

.changeset/tricky-yaks-unite.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-tools/utils': patch
3+
---
4+
5+
Revert https://github.com/ardatan/graphql-tools/pull/7683 which can cause unexpected breaking
6+
changes so as before the schema extension node will always be converted to a schema definition node

packages/utils/src/print-schema-with-directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function astFromSchema(
179179
}
180180

181181
const schemaNode: SchemaDefinitionNode | SchemaExtensionNode = {
182-
kind: operationTypes.length ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
182+
kind: operationTypes != null ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
183183
operationTypes,
184184
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
185185
directives: directives as any,

packages/utils/tests/print-schema-with-directives.spec.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
GraphQLString,
1414
printSchema,
1515
specifiedDirectives,
16-
stripIgnoredCharacters,
1716
} from 'graphql';
1817
import { GraphQLJSON } from 'graphql-scalars';
1918
import { makeExecutableSchema } from '@graphql-tools/schema';
@@ -403,17 +402,4 @@ describe('printSchemaWithDirectives', () => {
403402
expect(output).toContain('input OneOfInput @oneOf');
404403
}
405404
});
406-
it('prints a federation-style subgraph schema correctly', () => {
407-
const sdl = stripIgnoredCharacters(/* GraphQL */ `
408-
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])
409-
410-
type User @key(fields: "id") {
411-
id: ID!
412-
username: String
413-
}
414-
`);
415-
const userSubgraph = buildSchema(sdl, { assumeValid: true, assumeValidSDL: true });
416-
const printedSchema = stripIgnoredCharacters(printSchemaWithDirectives(userSubgraph));
417-
expect(printedSchema).toBe(sdl);
418-
});
419405
});

0 commit comments

Comments
 (0)