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

Introduce @authenticated directive in composition #2644

Merged
merged 17 commits into from
Jul 12, 2023

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Jun 28, 2023

This PR introduces the new @authenticated directive for composition

With this change, users can now compose @authenticated applications from their subgraphs into a supergraph. This addition will support a future version of Apollo Router that enables authenticated access to specific types and fields via directive applications.

Since the implementation of @authenticated is strictly a composition and execution concern, there's no change to the query planner with this work. The execution work is well under way in Apollo Router (and won't be built at all for Gateway). So as far as this repo is concerned, only composition is concerned with @authenticated.

TODO:

@changeset-bot
Copy link

changeset-bot bot commented Jun 28, 2023

🦋 Changeset detected

Latest commit: 70b695d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/composition Minor
@apollo/federation-internals Minor
@apollo/subgraph Minor
@apollo/gateway Minor
@apollo/query-planner Minor
@apollo/query-graphs Minor
apollo-federation-integration-testsuite Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jun 28, 2023

Deploy Preview for apollo-federation-docs canceled.

Name Link
🔨 Latest commit ad3b5e5
🔍 Latest deploy log https://app.netlify.com/sites/apollo-federation-docs/deploys/649f20470060fb0008a8a430

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 28, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@trevor-scheer trevor-scheer force-pushed the trevor/authenticated branch 2 times, most recently from 250504d to 1dccf3e Compare June 28, 2023 22:48
internals-js/src/authenticatedSpec.ts Outdated Show resolved Hide resolved
.changeset/gold-schools-flash.md Outdated Show resolved Hide resolved
internals-js/src/federationSpec.ts Outdated Show resolved Hide resolved
internals-js/src/federationSpec.ts Outdated Show resolved Hide resolved
composition-js/src/__tests__/compose.test.ts Outdated Show resolved Hide resolved
composition-js/src/__tests__/compose.test.ts Outdated Show resolved Hide resolved
@trevor-scheer trevor-scheer marked this pull request as ready for review June 29, 2023 20:55
@trevor-scheer trevor-scheer requested a review from a team as a code owner June 29, 2023 20:55
Copy link
Contributor

@pcmanus pcmanus left a comment

Choose a reason for hiding this comment

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

Left 2 test related comments but the patch lgtm so +1 (I'll still be happy if you fix my 2 test comments, but no need to re-review after that :)).

composition-js/src/__tests__/compose.test.ts Outdated Show resolved Hide resolved
internals-js/src/authenticatedSpec.ts Show resolved Hide resolved
@trevor-scheer trevor-scheer changed the base branch from main to next June 30, 2023 18:40
@trevor-scheer trevor-scheer force-pushed the trevor/authenticated branch 2 times, most recently from 500769d to 73b61ab Compare June 30, 2023 20:22
Copy link
Contributor

@clenfest clenfest left a comment

Choose a reason for hiding this comment

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

LGTM

@trevor-scheer trevor-scheer enabled auto-merge (squash) July 12, 2023 18:46
@trevor-scheer trevor-scheer merged commit 9396c0d into next Jul 12, 2023
10 checks passed
@trevor-scheer trevor-scheer deleted the trevor/authenticated branch July 12, 2023 18:48
pull bot pushed a commit to NOUIY/federation that referenced this pull request Nov 28, 2023
Introduce the new `@policy` scope for composition

> Note that this directive will only be _fully_ supported by the Apollo
Router as a GraphOS Enterprise feature at runtime. Also note that
_composition_ of valid `@policy` directive applications will succeed,
but the resulting supergraph will not be _executable_ by the Gateway or
an Apollo Router which doesn't have the GraphOS Enterprise entitlement.
  
Users may now compose `@policy` applications from their subgraphs into a
supergraph.

  The directive is defined as follows:

  ```graphql
  scalar federation__Policy

  directive @Policy(policies: [[federation__Policy!]!]!) on
    | FIELD_DEFINITION
    | OBJECT
    | INTERFACE
    | SCALAR
    | ENUM
  ```

The `Policy` scalar is effectively a `String`, similar to the `FieldSet`
type.

In order to compose your `@policy` usages, you must update your
subgraph's federation spec version to v2.6 and add the `@policy` import
to your existing imports like so:
  ```graphql
@link(url: "https://specs.apollo.dev/federation/v2.6", import: [...,
"@Policy"])
  ```

For additional context, this PR effectively follows the pattern
implemented by apollographql#2644

---------

Co-authored-by: Dariusz Kuc <9501705+dariuszkuc@users.noreply.github.com>
Co-authored-by: Geoffroy Couprie <apollo@geoffroycouprie.com>
Co-authored-by: Trevor Scheer <trevor.scheer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants