-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for [Federation specification v2.5](https://www.apollographql.com/docs/federation/federation-versions#v25). Changes: * new `@authenticated` directive ```graphql directive @authenticated on ENUM | FIELD_DEFINITION | INTERFACE | OBJECT | SCALAR ``` * new `@requiresScopes` directive ```graphql directive @requiresScopes(scopes: [[Scope!]!]!) on ENUM | FIELD_DEFINITION | INTERFACE | OBJECT | SCALAR scalar Scope ```
- Loading branch information
1 parent
e78025f
commit 0ad2582
Showing
11 changed files
with
256 additions
and
7 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM gradle:8.2.1-jdk17 | ||
FROM openjdk:17 | ||
|
||
EXPOSE 4001 | ||
RUN mkdir /app | ||
|
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
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
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
83 changes: 83 additions & 0 deletions
83
graphql-java-support/src/main/resources/definitions_fed2_5.graphqls
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,83 @@ | ||
# | ||
# https://specs.apollo.dev/federation/v2.0/federation-v2.0.graphql | ||
# | ||
|
||
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
directive @requires(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @provides(fields: FieldSet!) on FIELD_DEFINITION | ||
directive @external on OBJECT | FIELD_DEFINITION | ||
directive @extends on OBJECT | INTERFACE | ||
directive @override(from: String!) on FIELD_DEFINITION | ||
directive @inaccessible on | ||
| FIELD_DEFINITION | ||
| OBJECT | ||
| INTERFACE | ||
| UNION | ||
| ENUM | ||
| ENUM_VALUE | ||
| SCALAR | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
| ARGUMENT_DEFINITION | ||
directive @tag(name: String!) repeatable on | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| UNION | ||
| ARGUMENT_DEFINITION | ||
| SCALAR | ||
| ENUM | ||
| ENUM_VALUE | ||
| INPUT_OBJECT | ||
| INPUT_FIELD_DEFINITION | ||
scalar FieldSet | ||
|
||
# | ||
# https://specs.apollo.dev/link/v1.0/link-v1.0.graphql | ||
# | ||
|
||
directive @link( | ||
url: String!, | ||
as: String, | ||
import: [Import]) | ||
repeatable on SCHEMA | ||
|
||
scalar Import | ||
|
||
# | ||
# federation-v2.1 | ||
# | ||
|
||
directive @composeDirective(name: String!) repeatable on SCHEMA | ||
|
||
# | ||
# federation-v2.2 | ||
# | ||
|
||
directive @shareable repeatable on FIELD_DEFINITION | OBJECT | ||
|
||
# | ||
# federation-v2.3 | ||
# | ||
|
||
directive @interfaceObject on OBJECT | ||
|
||
# | ||
# federation-v2.5 | ||
# | ||
|
||
directive @authenticated on | ||
ENUM | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| SCALAR | ||
|
||
directive @requiresScopes(scopes: [[Scope!]!]!) on | ||
ENUM | ||
| FIELD_DEFINITION | ||
| INTERFACE | ||
| OBJECT | ||
| SCALAR | ||
|
||
scalar Scope |
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
11 changes: 11 additions & 0 deletions
11
graphql-java-support/src/test/resources/schemas/authorization.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,11 @@ | ||
extend schema @link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@authenticated", "@key", "@requiresScopes", "Scope", "FieldSet"]) | ||
|
||
type Product @key(fields: "id") { | ||
id: ID! | ||
name: String! | ||
supplier: String @requiresScopes(scopes: [["scopeA"]]) | ||
} | ||
|
||
type Query { | ||
product(id: ID!): Product @authenticated | ||
} |
57 changes: 57 additions & 0 deletions
57
graphql-java-support/src/test/resources/schemas/authorization_federated.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,57 @@ | ||
schema @link(import : ["@authenticated", "@key", "@requiresScopes", "Scope", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.5"){ | ||
query: Query | ||
} | ||
|
||
directive @authenticated on SCALAR | OBJECT | FIELD_DEFINITION | INTERFACE | ENUM | ||
|
||
directive @federation__composeDirective(name: String!) repeatable on SCHEMA | ||
|
||
directive @federation__extends on OBJECT | INTERFACE | ||
|
||
directive @federation__external on OBJECT | FIELD_DEFINITION | ||
|
||
directive @federation__interfaceObject on OBJECT | ||
|
||
directive @federation__override(from: String!) on FIELD_DEFINITION | ||
|
||
directive @federation__provides(fields: FieldSet!) on FIELD_DEFINITION | ||
|
||
directive @federation__requires(fields: FieldSet!) on FIELD_DEFINITION | ||
|
||
directive @federation__shareable repeatable on OBJECT | FIELD_DEFINITION | ||
|
||
directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
|
||
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
|
||
directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA | ||
|
||
directive @requiresScopes(scopes: [[Scope!]!]!) on SCALAR | OBJECT | FIELD_DEFINITION | INTERFACE | ENUM | ||
|
||
directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
|
||
union _Entity = Product | ||
|
||
type Product @key(fields : "id", resolvable : true) { | ||
id: ID! | ||
name: String! | ||
supplier: String @requiresScopes(scopes : [["scopeA"]]) | ||
} | ||
|
||
type Query { | ||
_entities(representations: [_Any!]!): [_Entity]! | ||
_service: _Service! | ||
product(id: ID!): Product @authenticated | ||
} | ||
|
||
type _Service { | ||
sdl: String! | ||
} | ||
|
||
scalar FieldSet | ||
|
||
scalar Scope | ||
|
||
scalar _Any | ||
|
||
scalar link__Import |
13 changes: 13 additions & 0 deletions
13
graphql-java-support/src/test/resources/schemas/customAuthenticated.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,13 @@ | ||
extend schema @link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key"]) | ||
|
||
directive @authenticated(role: [String!]!) on FIELD_DEFINITION | ||
|
||
type Product @key(fields: "id") { | ||
id: ID! | ||
name: String! | ||
supplier: String @authenticated(role: ["manager"]) | ||
} | ||
|
||
type Query { | ||
product(id: ID!): Product | ||
} |
59 changes: 59 additions & 0 deletions
59
graphql-java-support/src/test/resources/schemas/customAuthenticated_federated.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,59 @@ | ||
schema @link(import : ["@key"], url : "https://specs.apollo.dev/federation/v2.5"){ | ||
query: Query | ||
} | ||
|
||
directive @authenticated(role: [String!]!) on FIELD_DEFINITION | ||
|
||
directive @federation__authenticated on SCALAR | OBJECT | FIELD_DEFINITION | INTERFACE | ENUM | ||
|
||
directive @federation__composeDirective(name: String!) repeatable on SCHEMA | ||
|
||
directive @federation__extends on OBJECT | INTERFACE | ||
|
||
directive @federation__external on OBJECT | FIELD_DEFINITION | ||
|
||
directive @federation__interfaceObject on OBJECT | ||
|
||
directive @federation__override(from: String!) on FIELD_DEFINITION | ||
|
||
directive @federation__provides(fields: federation__FieldSet!) on FIELD_DEFINITION | ||
|
||
directive @federation__requires(fields: federation__FieldSet!) on FIELD_DEFINITION | ||
|
||
directive @federation__requiresScopes(scopes: [[federation__Scope!]!]!) on SCALAR | OBJECT | FIELD_DEFINITION | INTERFACE | ENUM | ||
|
||
directive @federation__shareable repeatable on OBJECT | FIELD_DEFINITION | ||
|
||
directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
|
||
directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||
|
||
directive @link(as: String, import: [link__Import], url: String!) repeatable on SCHEMA | ||
|
||
directive @tag(name: String!) repeatable on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||
|
||
union _Entity = Product | ||
|
||
type Product @key(fields : "id", resolvable : true) { | ||
id: ID! | ||
name: String! | ||
supplier: String @authenticated(role : ["manager"]) | ||
} | ||
|
||
type Query { | ||
_entities(representations: [_Any!]!): [_Entity]! | ||
_service: _Service! | ||
product(id: ID!): Product | ||
} | ||
|
||
type _Service { | ||
sdl: String! | ||
} | ||
|
||
scalar _Any | ||
|
||
scalar federation__FieldSet | ||
|
||
scalar federation__Scope | ||
|
||
scalar link__Import |