Skip to content

Commit

Permalink
add support for federation 2.4, 2.5 and 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nogates committed Feb 14, 2024
1 parent f8b3560 commit e86b43a
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 0 deletions.
63 changes: 63 additions & 0 deletions ariadne/contrib/federation/definitions/fed2_4.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# 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

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# 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.2
#

directive @shareable repeatable on FIELD_DEFINITION | OBJECT

#
# federation-v2.3
#

directive @interfaceObject on OBJECT
84 changes: 84 additions & 0 deletions ariadne/contrib/federation/definitions/fed2_5.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# 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

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# 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.2
#

directive @shareable repeatable on FIELD_DEFINITION | OBJECT

#
# federation-v2.3
#

directive @interfaceObject on OBJECT

#
# federation-v2.5
#

directive @authenticated on
FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM

scalar federation__Scope

directive @requiresScopes(scopes: [[federation__Scope!]!]!) on
FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM

95 changes: 95 additions & 0 deletions ariadne/contrib/federation/definitions/fed2_6.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# 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

#
# federation-v2.1
#

directive @composeDirective(name: String!) repeatable on SCHEMA

#
# 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.2
#

directive @shareable repeatable on FIELD_DEFINITION | OBJECT

#
# federation-v2.3
#

directive @interfaceObject on OBJECT

#
# federation-v2.5
#

directive @authenticated on
FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM

scalar federation__Scope

directive @requiresScopes(scopes: [[federation__Scope!]!]!) on
FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM

#
# federation-v2.5
#

scalar federation__Policy
directive @policy(policies: [[federation__Policy!]!]!) on
| FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM
12 changes: 12 additions & 0 deletions ariadne/contrib/federation/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ def make_federated_schema(
definitions = load_schema_from_path(
os.path.join(dirname, "./definitions/fed2_3.graphql")
)
elif link and link.group(1) == "https://specs.apollo.dev/federation/v2.4":
definitions = load_schema_from_path(
os.path.join(dirname, "./definitions/fed2_4.graphql")
)
elif link and link.group(1) == "https://specs.apollo.dev/federation/v2.5":
definitions = load_schema_from_path(
os.path.join(dirname, "./definitions/fed2_5.graphql")
)
elif link and link.group(1) == "https://specs.apollo.dev/federation/v2.6":
definitions = load_schema_from_path(
os.path.join(dirname, "./definitions/fed2_6.graphql")
)
else:
definitions = load_schema_from_path(
os.path.join(dirname, "./definitions/fed1_0.graphql")
Expand Down
4 changes: 4 additions & 0 deletions ariadne/contrib/federation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
"inaccessible", # Federation 2 directive.
"composeDirective", # Federation 2.1 directive.
"interfaceObject", # Federation 2.3 directive.
"authenticated", # Federation 2.5 directive.
"requiresScopes", # Federation 2.5 directive.
"policy", # Federation 2.6 directive.

]


Expand Down
Loading

0 comments on commit e86b43a

Please sign in to comment.