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

Add the ability to reference elements further up the call chain as named parameters #2988

Merged
merged 85 commits into from
May 14, 2024

Conversation

clenfest
Copy link
Contributor

Query planning and composition work for adding @fromcontext and @context along with bump federation to version 2.8 to accommodate.

@clenfest clenfest requested a review from a team as a code owner April 22, 2024 15:28
Copy link

changeset-bot bot commented Apr 22, 2024

🦋 Changeset detected

Latest commit: dd72c8e

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

This PR includes changesets to release 7 packages
Name Type
@apollo/query-planner Minor
@apollo/query-graphs Minor
@apollo/composition Minor
@apollo/federation-internals Minor
@apollo/gateway Minor
@apollo/subgraph 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

Copy link

codesandbox-ci bot commented Apr 22, 2024

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.

Copy link
Contributor Author

@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.

It looks like I broke something in query planning, so I have to fix up the tests. Other than that there are a couple of outstanding issues.

  1. The main issue that I have left is that I'm not sure of the best place to make sure the argument is added to the query plan. For some reason, the trigger inside of the GraphPath does not have an argument on it. I'm really not sure why this is, as if I look at the transition for the edge, it is there. I'm not sure if the best approach is to figure out why the trigger isn't what I think it should be or to just fix it all up in toPlanNode(). I think this is related to the fact that the argument exists in subgraphs, but not in the supergraph.
  2. There is a hack inside of Field.validate where I'm ignoring mission arguments from variableDefinitions if the argument is contextual. Not sure how to do this right.
  3. If a context is set and used in the same fetch group, I separate it into two so that the router can insert the correct variableDefinitions on the second invocation. This mostly works, but there is an outstanding issue where I'm fetching the type in both FetchGroups currently.
  4. I broke a bunch of query planning tests. I'm sure it's something minor, but be aware.

Copy link
Contributor

@sachindshinde sachindshinde left a comment

Choose a reason for hiding this comment

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

This is a partial review, specifically for subgraph validation. I'll get the merge logic later today, and (I think) the query planning/satisfiability later tomorrow.

Some assumptions I'm making:

  1. There are several asserts, but I'm assuming that if they throw they'll be translated to user errors (at the least, we don't want composition to throw).
  2. It looks like we're only supporting inline fragments at the top-level of field values (which is fine to start with).

internals-js/src/specs/contextSpec.ts Outdated Show resolved Hide resolved
internals-js/src/specs/contextSpec.ts Outdated Show resolved Hide resolved
internals-js/src/specs/federationSpec.ts Outdated Show resolved Hide resolved
internals-js/src/specs/joinSpec.ts Outdated Show resolved Hide resolved
internals-js/src/supergraphs.ts Show resolved Hide resolved
internals-js/src/federation.ts Outdated Show resolved Hide resolved
internals-js/src/federation.ts Outdated Show resolved Hide resolved
internals-js/src/federation.ts Outdated Show resolved Hide resolved
internals-js/src/federation.ts Show resolved Hide resolved
internals-js/src/federation.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@sachindshinde sachindshinde left a comment

Choose a reason for hiding this comment

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

Pair programmed on this with @clenfest for remaining issues, looks good to me! Great job 🚀 !

@clenfest clenfest merged commit c4744da into next May 14, 2024
15 checks passed
@clenfest clenfest deleted the clenfest/setContext-qp branch May 14, 2024 04:01
clenfest pushed a commit that referenced this pull request May 14, 2024
…#3005)

This PR makes some changes to #2988, specifically:
- It fixes a bug where the relative path is computed incorrectly when a
subgraph jump is skipped/elided in the case of `@fromContext`.
- It changes the selection-set-to-renamer conversion logic to create
multiple inline fragments instead of introducing a new syntax, in the
case of a type condition on an abstract type. (This saves us from having
to update router to understand it.)
- It tweaks the iteration over the `GraphPath` in
`canSatisfyConditions()` to be cleaner/easier to understand.
- When I looked at that code again, I noticed it was strange that we
initialized `levelsInDataPath` at `1` even though we aren't guaranteed
that the last element in `GraphPath` is a field. The gist is that at the
first match, we know it's a field, so that ends up being okay. But I
think it's easier to understand code-wise if both `levelsInQueryPath`
and `levelsInDataPath` start off at 0, and every time we get a new
element (at the start of the `for` block) we increment the counts
accordingly.
clenfest pushed a commit that referenced this pull request May 17, 2024
# Releases
## @apollo/composition@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/query-graphs@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/gateway@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`daf36bd242ba4db0cfcf0e18c1eed235ff0dfaf2`](daf36bd)]:
    -   @apollo/query-planner@2.8.0-alpha.0
    -   @apollo/composition@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/federation-internals@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

## @apollo/query-graphs@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/query-planner@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Fix relative path logic when eliding subgraph jumps for `@fromContext`
([#3005](#3005))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/query-graphs@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/subgraph@2.8.0-alpha.0

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/federation-internals@2.8.0-alpha.0

## apollo-federation-integration-testsuite@2.8.0-alpha.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
clenfest pushed a commit that referenced this pull request May 29, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to next, this PR will
be updated.


# Releases
## @apollo/composition@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/gateway@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`daf36bd242ba4db0cfcf0e18c1eed235ff0dfaf2`](daf36bd)]:
    -   @apollo/query-planner@2.8.0
    -   @apollo/composition@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/federation-internals@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

## @apollo/query-graphs@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Fix bug in context-matching logic for
interfaces-implementing-interfaces (#3014)
([#3015](#3015))

A field is considered to match a context if the field's parent type (in
the original query) either has `@context` on it, or implements/is a
member of a type with `@context` on it. We ended up missing the case
where interfaces implement interfaces; this PR introduces a fix.

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7)]:
    -   @apollo/federation-internals@2.8.0

## @apollo/query-planner@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Fix relative path logic when eliding subgraph jumps for `@fromContext`
([#3005](#3005))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/subgraph@2.8.0

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7)]:
    -   @apollo/federation-internals@2.8.0

## apollo-federation-integration-testsuite@2.8.0

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Meschreiber pushed a commit that referenced this pull request Jun 17, 2024
…med parameters (#2988)

Query planning and composition work for adding @fromcontext and @context
along with bump federation to version 2.8 to accommodate.

---------

Co-authored-by: o0Ignition0o <jeremy.lempereur@gmail.com>
Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
Meschreiber pushed a commit that referenced this pull request Jun 17, 2024
…#3005)

This PR makes some changes to #2988, specifically:
- It fixes a bug where the relative path is computed incorrectly when a
subgraph jump is skipped/elided in the case of `@fromContext`.
- It changes the selection-set-to-renamer conversion logic to create
multiple inline fragments instead of introducing a new syntax, in the
case of a type condition on an abstract type. (This saves us from having
to update router to understand it.)
- It tweaks the iteration over the `GraphPath` in
`canSatisfyConditions()` to be cleaner/easier to understand.
- When I looked at that code again, I noticed it was strange that we
initialized `levelsInDataPath` at `1` even though we aren't guaranteed
that the last element in `GraphPath` is a field. The gist is that at the
first match, we know it's a field, so that ends up being okay. But I
think it's easier to understand code-wise if both `levelsInQueryPath`
and `levelsInDataPath` start off at 0, and every time we get a new
element (at the start of the `for` block) we increment the counts
accordingly.
Meschreiber pushed a commit that referenced this pull request Jun 17, 2024
# Releases
## @apollo/composition@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/query-graphs@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/gateway@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`daf36bd242ba4db0cfcf0e18c1eed235ff0dfaf2`](daf36bd)]:
    -   @apollo/query-planner@2.8.0-alpha.0
    -   @apollo/composition@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/federation-internals@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

## @apollo/query-graphs@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/query-planner@2.8.0-alpha.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Fix relative path logic when eliding subgraph jumps for `@fromContext`
([#3005](#3005))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/query-graphs@2.8.0-alpha.0
    -   @apollo/federation-internals@2.8.0-alpha.0

## @apollo/subgraph@2.8.0-alpha.0

### Patch Changes

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da)]:
    -   @apollo/federation-internals@2.8.0-alpha.0

## apollo-federation-integration-testsuite@2.8.0-alpha.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Meschreiber pushed a commit that referenced this pull request Jun 17, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to next, this PR will
be updated.


# Releases
## @apollo/composition@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/gateway@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`daf36bd242ba4db0cfcf0e18c1eed235ff0dfaf2`](daf36bd)]:
    -   @apollo/query-planner@2.8.0
    -   @apollo/composition@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/federation-internals@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

## @apollo/query-graphs@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Fix bug in context-matching logic for
interfaces-implementing-interfaces (#3014)
([#3015](#3015))

A field is considered to match a context if the field's parent type (in
the original query) either has `@context` on it, or implements/is a
member of a type with `@context` on it. We ended up missing the case
where interfaces implement interfaces; this PR introduces a fix.

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7)]:
    -   @apollo/federation-internals@2.8.0

## @apollo/query-planner@2.8.0

### Minor Changes

- Implement new directives to allow getting and setting context. This
allows resolvers to reference and access data referenced by entities
that exist in the GraphPath that was used to access the field. The
following example demonstrates the ability to access the `prop` field
within the Child resolver.
([#2988](#2988))

    ```graphql
    type Query {
      p: Parent!
    }
    type Parent @key(fields: "id") @context(name: "context") {
      id: ID!
      child: Child!
      prop: String!
    }
    type Child @key(fields: "id") {
      id: ID!
      b: String!
      field(a: String @fromcontext(field: "$context { prop }")): Int!
    }
    ```

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Fix relative path logic when eliding subgraph jumps for `@fromContext`
([#3005](#3005))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7),
[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0
    -   @apollo/federation-internals@2.8.0

## @apollo/subgraph@2.8.0

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

- Updated dependencies
\[[`c4744da360235d8bb8270ea048f0e0fa5d03be1e`](c4744da),
[`8a936d741a0c05835ff2533714cf330d18209179`](8a936d7)]:
    -   @apollo/federation-internals@2.8.0

## apollo-federation-integration-testsuite@2.8.0

### Patch Changes

- Various set context bugfixes
([#3017](#3017))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.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.

5 participants