Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle @inaccessible on types & more Federation tests (#6086)
* Handle @inaccessible on types & more Federation tests * Add Fed v1 test
- Loading branch information
Showing
10 changed files
with
435 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@graphql-tools/federation": patch | ||
--- | ||
|
||
Handle @inaccessible types correctly |
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
58 changes: 58 additions & 0 deletions
58
...ederation/test/fixtures/federation-compatibility/fed1-external-extends/supergraph.graphql
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,58 @@ | ||
schema | ||
@link(url: "https://specs.apollo.dev/link/v1.0") | ||
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) | ||
{ | ||
query: Query | ||
} | ||
|
||
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE | ||
|
||
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ||
|
||
directive @join__graph(name: String!, url: String!) on ENUM_VALUE | ||
|
||
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE | ||
|
||
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR | ||
|
||
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION | ||
|
||
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA | ||
|
||
scalar join__FieldSet | ||
|
||
enum join__Graph { | ||
A @join__graph(name: "a", url: "https://federation-compatibility.theguild.workers.dev/fed1-external-extends/a") | ||
B @join__graph(name: "b", url: "https://federation-compatibility.theguild.workers.dev/fed1-external-extends/b") | ||
} | ||
|
||
scalar link__Import | ||
|
||
enum link__Purpose { | ||
""" | ||
`SECURITY` features provide metadata necessary to securely resolve fields. | ||
""" | ||
SECURITY | ||
|
||
""" | ||
`EXECUTION` features provide metadata necessary for operation execution. | ||
""" | ||
EXECUTION | ||
} | ||
|
||
type Query | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
randomUser: User @join__field(graph: A) | ||
userById(id: ID): User @join__field(graph: B) | ||
} | ||
|
||
type User | ||
@join__type(graph: A, key: "id") | ||
@join__type(graph: B, key: "id") | ||
{ | ||
id: ID! | ||
name: String! @join__field(graph: B) | ||
nickname: String @join__field(graph: B) | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/federation/test/fixtures/federation-compatibility/fed1-external-extends/tests.json
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,18 @@ | ||
[ | ||
{ | ||
"query": "\n query {\n randomUser {\n id\n name\n }\n userById(id: \"u2\") {\n id\n name\n nickname\n }\n }\n ", | ||
"expected": { | ||
"data": { | ||
"randomUser": { | ||
"id": "u1", | ||
"name": "u1-name" | ||
}, | ||
"userById": { | ||
"id": "u2", | ||
"name": "u2-name", | ||
"nickname": "u2-nickname" | ||
} | ||
} | ||
} | ||
} | ||
] |
86 changes: 86 additions & 0 deletions
86
...s/federation/test/fixtures/federation-compatibility/requires-interface/supergraph.graphql
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,86 @@ | ||
schema | ||
@link(url: "https://specs.apollo.dev/link/v1.0") | ||
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) | ||
{ | ||
query: Query | ||
} | ||
|
||
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE | ||
|
||
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ||
|
||
directive @join__graph(name: String!, url: String!) on ENUM_VALUE | ||
|
||
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE | ||
|
||
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR | ||
|
||
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION | ||
|
||
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA | ||
|
||
interface Address | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
id: ID! | ||
} | ||
|
||
type HomeAddress implements Address | ||
@join__implements(graph: A, interface: "Address") | ||
@join__implements(graph: B, interface: "Address") | ||
@join__type(graph: A, key: "id") | ||
@join__type(graph: B, key: "id") | ||
{ | ||
id: ID! | ||
city: String | ||
} | ||
|
||
scalar join__FieldSet | ||
|
||
enum join__Graph { | ||
A @join__graph(name: "a", url: "https://federation-compatibility.theguild.workers.dev/requires-interface/a") | ||
B @join__graph(name: "b", url: "https://federation-compatibility.theguild.workers.dev/requires-interface/b") | ||
} | ||
|
||
scalar link__Import | ||
|
||
enum link__Purpose { | ||
""" | ||
`SECURITY` features provide metadata necessary to securely resolve fields. | ||
""" | ||
SECURITY | ||
|
||
""" | ||
`EXECUTION` features provide metadata necessary for operation execution. | ||
""" | ||
EXECUTION | ||
} | ||
|
||
type Query | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
a: User @join__field(graph: A) | ||
b: User @join__field(graph: B) | ||
} | ||
|
||
type User | ||
@join__type(graph: A, key: "id") | ||
@join__type(graph: B, key: "id") | ||
{ | ||
id: ID! | ||
name: String! | ||
address: Address @join__field(graph: A, external: true) @join__field(graph: B) | ||
city: String @join__field(graph: A, requires: "address { id }") | ||
} | ||
|
||
type WorkAddress implements Address | ||
@join__implements(graph: A, interface: "Address") | ||
@join__implements(graph: B, interface: "Address") | ||
@join__type(graph: A, key: "id") | ||
@join__type(graph: B, key: "id") | ||
{ | ||
id: ID! | ||
city: String | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/federation/test/fixtures/federation-compatibility/requires-interface/tests.json
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,48 @@ | ||
[ | ||
{ | ||
"query": "\n query {\n a {\n city\n }\n }\n ", | ||
"expected": { | ||
"data": { | ||
"a": { | ||
"city": "a1-city" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"query": "\n query {\n b {\n city\n }\n }\n ", | ||
"expected": { | ||
"data": { | ||
"b": { | ||
"city": "a2-city" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"query": "\n query {\n a {\n address {\n __typename\n id\n }\n }\n }\n ", | ||
"expected": { | ||
"data": { | ||
"a": { | ||
"address": { | ||
"__typename": "HomeAddress", | ||
"id": "a1" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"query": "\n query {\n b {\n address {\n __typename\n id\n }\n }\n }\n ", | ||
"expected": { | ||
"data": { | ||
"b": { | ||
"address": { | ||
"__typename": "WorkAddress", | ||
"id": "a2" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] |
107 changes: 107 additions & 0 deletions
107
...eration/test/fixtures/federation-compatibility/requires-with-fragments/supergraph.graphql
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,107 @@ | ||
schema | ||
@link(url: "https://specs.apollo.dev/link/v1.0") | ||
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) | ||
@link(url: "https://specs.apollo.dev/inaccessible/v0.2", for: SECURITY) | ||
{ | ||
query: Query | ||
} | ||
|
||
directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
|
||
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE | ||
|
||
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ||
|
||
directive @join__graph(name: String!, url: String!) on ENUM_VALUE | ||
|
||
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE | ||
|
||
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR | ||
|
||
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION | ||
|
||
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA | ||
|
||
interface Bar implements Foo | ||
@join__implements(graph: A, interface: "Foo") | ||
@join__implements(graph: B, interface: "Foo") | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
foo: String! | ||
bar: String! | ||
} | ||
|
||
type Baz implements Foo & Bar | ||
@join__implements(graph: A, interface: "Foo") | ||
@join__implements(graph: A, interface: "Bar") | ||
@join__implements(graph: B, interface: "Foo") | ||
@join__implements(graph: B, interface: "Bar") | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
@inaccessible | ||
{ | ||
foo: String! | ||
bar: String! | ||
baz: String! | ||
} | ||
|
||
type Entity | ||
@join__type(graph: A, key: "id") | ||
@join__type(graph: B, key: "id") | ||
{ | ||
id: ID! | ||
data: Foo @join__field(graph: A) @join__field(graph: B, external: true) | ||
requirer: String! @join__field(graph: B, requires: "data {\n foo\n ... on Bar {\n bar\n ... on Baz {\n baz\n }\n ... on Qux {\n qux\n }\n }\n}") | ||
requirer2: String! @join__field(graph: B, requires: "data {\n ... on Foo {\n foo\n }\n}") | ||
} | ||
|
||
interface Foo | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
foo: String! | ||
} | ||
|
||
scalar join__FieldSet | ||
|
||
enum join__Graph { | ||
A @join__graph(name: "a", url: "https://federation-compatibility.theguild.workers.dev/requires-with-fragments/a") | ||
B @join__graph(name: "b", url: "https://federation-compatibility.theguild.workers.dev/requires-with-fragments/b") | ||
} | ||
|
||
scalar link__Import | ||
|
||
enum link__Purpose { | ||
""" | ||
`SECURITY` features provide metadata necessary to securely resolve fields. | ||
""" | ||
SECURITY | ||
|
||
""" | ||
`EXECUTION` features provide metadata necessary for operation execution. | ||
""" | ||
EXECUTION | ||
} | ||
|
||
type Query | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
a: Entity @join__field(graph: A) | ||
b: Entity @join__field(graph: B) | ||
bb: Entity @join__field(graph: B) | ||
} | ||
|
||
type Qux implements Foo & Bar | ||
@join__implements(graph: A, interface: "Foo") | ||
@join__implements(graph: A, interface: "Bar") | ||
@join__implements(graph: B, interface: "Foo") | ||
@join__implements(graph: B, interface: "Bar") | ||
@join__type(graph: A) | ||
@join__type(graph: B) | ||
{ | ||
foo: String! | ||
bar: String! | ||
qux: String! | ||
} |
Oops, something went wrong.