-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apollo-graphql): support complex directive args (#2335)
This change fixes `transformSchema`, which previously left directives as-is after transforming types. This meant that Input types used in directive arguments would appear duplicated in the schema. It now recreates schema directives and their arguments like it does with named schema types. Fixes #2162
- Loading branch information
1 parent
6ff7ccd
commit 7753ddc
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/apollo-graphql/src/schema/__tests__/transformSchema.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { buildSchema, printSchema } from "graphql"; | ||
import { transformSchema } from "../transformSchema"; | ||
|
||
describe("transformSchema", () => { | ||
test("no-op transform leaves types untouched", () => { | ||
const schema = buildSchema(`#graphql | ||
type Query { | ||
foo: String @test(baz: { bar: "hello" }) | ||
} | ||
input DirectiveArg { | ||
bar: String | ||
} | ||
# https://github.com/apollographql/apollo-tooling/issues/2162 | ||
directive @test(baz: DirectiveArg) on FIELD_DEFINITION | ||
`); | ||
|
||
const newSchema = transformSchema(schema, namedType => namedType); | ||
|
||
expect(printSchema(newSchema)).toEqual(printSchema(schema)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters