wundergraph / graphql-go-tools

GraphQL Router / API Gateway framework written in Golang, focussing on correctness, extensibility, and high-performance. Supports Federation v1 & v2, Subscriptions & more.
https://graphql-api-gateway.com
MIT License
687 stars 130 forks source link

WunderGraph Router Doesn't Resolve Key Field with Multiple Keys When Using @external and @provides #931

Closed apatelWU closed 1 week ago

apatelWU commented 1 week ago

Description:

I am experiencing an issue with WunderGraph Router where it fails to resolve a key field defined with multiple keys when using @external and @provides across federated subgraphs.

Subgraphs:

Subgraph A

type A @key(fields: "ax") @key(fields: "ay") {
  ax: ID!
  ay: String!
  az: String
}

Subgraph B

type A @key(fields: "ax", resolvable: false) @key(fields: "ay", resolvable: false) {
  ax: ID! @external
  ay: String! @external
}

type B {
  bx: ID! 
  by: String
  bz: String
  a: A! @provides(fields: "ax")
}

Steps to Reproduce

  1. Define Subgraph A and Subgraph B as shown above.
  2. Query the router with the following:

Query 1 (Works as expected)

query Test1 {
  getB() {
    bx
    by
    a {
      ax
      az
    }
  }
}

This query successfully fetches the az field from Subgraph A

Query 2 (Fails to resolve correctly)

query Test1 {
  getB() {
    bx
    by
    a {
      ax
      ay
      az
    }
  }
}

This query does not fetch the ay field from Subgraph A and incorrectly attempts to resolve it from Subgraph B, despite it being marked as @external.

Expected Behavior

The router should be able to resolve the ay field from Subgraph A when queried alongside the other fields, given that at least one key is provided.

Version

WGC version: 0.66.0 router version: 0.115.0 (https://github.com/wundergraph/cosmo/releases/tag/router%400.115.0)

devsergiy commented 1 week ago

Hi @apatelWU

Please clarify which router you are referring to and which versions you use.

apatelWU commented 1 week ago

@devsergiy - update the ticket with versions and link to the router

Aenimus commented 1 week ago

@apatelWU Please update composition and the router to the latest versions as a first step before reporting bugs.

Please kindly try again with the latest versions, and let us know the result.

Thanks!

apatelWU commented 1 week ago

New versions are working as expected. Thanks!