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

Fix bug in context-matching logic for interfaces-implementing-interfaces #3014

Conversation

sachindshinde
Copy link
Contributor

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.

…or implements/is a member of a type with @context on it. We'd missed interfaces-implementing-interfaces in the existing code.
@sachindshinde sachindshinde requested a review from a team as a code owner May 22, 2024 17:48
Copy link

changeset-bot bot commented May 22, 2024

⚠️ No Changeset found

Latest commit: cb024c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

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.

@clenfest clenfest merged commit 907babf into apollographql:next May 22, 2024
15 checks passed
clenfest added a commit that referenced this pull request May 22, 2024
clenfest added a commit that referenced this pull request May 22, 2024
clenfest pushed a commit that referenced this pull request May 22, 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.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @apollo/composition@2.8.0-alpha.1

### Patch Changes

- Updated dependencies
\[[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

-   Updated dependencies \[]:
    -   @apollo/composition@2.8.0-alpha.1
    -   @apollo/query-planner@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

- 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 \[]:
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

- Updated dependencies
\[[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

-   Updated dependencies \[]:
    -   @apollo/federation-internals@2.8.0-alpha.1

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



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

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
…ces (#3014)

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.
Meschreiber pushed a commit that referenced this pull request Jun 17, 2024
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.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @apollo/composition@2.8.0-alpha.1

### Patch Changes

- Updated dependencies
\[[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

-   Updated dependencies \[]:
    -   @apollo/composition@2.8.0-alpha.1
    -   @apollo/query-planner@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

- 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 \[]:
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

- Updated dependencies
\[[`f5fe3e74d36722f78004c1e2e03c77d8b95cd6bf`](f5fe3e7)]:
    -   @apollo/query-graphs@2.8.0-alpha.1
    -   @apollo/federation-internals@2.8.0-alpha.1

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

### Patch Changes

-   Updated dependencies \[]:
    -   @apollo/federation-internals@2.8.0-alpha.1

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



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

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.

3 participants