Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: federation 2.5 support #347

Merged
merged 2 commits into from
Sep 6, 2023

Conversation

dariuszkuc
Copy link
Member

@dariuszkuc dariuszkuc commented Sep 5, 2023

Adds support for Federation specification v2.5.

Changes:

  • new @authenticated directive
directive @authenticated on
    ENUM
  | FIELD_DEFINITION
  | INTERFACE
  | OBJECT
  | SCALAR
  • new @requiresScopes directive
directive @requiresScopes(scopes: [[Scope!]!]!) on
    ENUM
  | FIELD_DEFINITION
  | INTERFACE
  | OBJECT
  | SCALAR

scalar Scope

Adds support for Federation specification v2.5.

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
```
@dariuszkuc dariuszkuc changed the title chore: update compatibility test to use fed 2.5 feat: federation 2.5 support Sep 6, 2023
@dariuszkuc dariuszkuc requested a review from a team September 6, 2023 16:23
@dariuszkuc dariuszkuc added the change: minor New functionality added in backwards compatible manner label Sep 6, 2023
Comment on lines +1 to +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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it's less of a concern for requiresScopes but might be nice to have a similar test for completeness.

| OBJECT
| SCALAR

scalar Scope
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this needs to be federation__Scope everywhere it's defined and referenced by @requiresScopes. I would expect a composition error / incompatible definition for this.

Invalid definition for directive "@requiresScopes": argument "scopes" should have type "[[federation__Scope!]!]!" but found type "[[Scope!]!]!"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

federation__ namespace prefix should only be required if given directive/type is not explicitly imported (see the diff between the custom authenticated directive with no imports and default authorization with imports

Copy link
Member

@trevor-scheer trevor-scheer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm not really privy to the java-related changes but they seem reasonable.

@dariuszkuc dariuszkuc merged commit 0ad2582 into apollographql:main Sep 6, 2023
2 checks passed
@dariuszkuc dariuszkuc deleted the compatibility branch September 6, 2023 18:16
dariuszkuc added a commit that referenced this pull request Oct 10, 2024
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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change: minor New functionality added in backwards compatible manner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants