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

Adding a field changes the returned value of another (@requires directive with arguments involved) #2996

Open
rickbijkerk opened this issue Apr 22, 2024 · 2 comments

Comments

@rickbijkerk
Copy link

rickbijkerk commented Apr 22, 2024

Describe the bug
Below a simplified description of the use case we're experiencing.

The problem: Query 1 and query 2 give a different response on 'explicit' field.

When looking at what apollo router sends to the subgraphs; The router send a request to schema 1 to fetch the attributes for
Query 1: with the arguments required by the @requires definition in the schema (@requires(fields:"attributes(keys:\"Erotic Content\")}")})
Query 2: with the arguments of the 'attributes' field.

Not sure exactly how it would work but the only way for this to work properly is if apollo would send 2 seperate queries for fetching the attributes field with different arguments

Query 1

query{
  product(id: "123") {
     explicit
  }
}

Query 2

query{
  product(id: "123") {
    explicit
    attributes (keys:"size")
  }
}

Schema 1 (product)

type Query {
    product(id: ID!): Product
}

type Product @key(fields: "id") {
    id: ID!
    attributes(keys: [String!]): [String!]
}

Schema 2 (product enrichment)

type Product @key(fields: "id") {
    id: ID!
    attributes(keys: [String!]): [String!] @external
    explicit: Boolean @requires(fields: "attributes(keys:\"Erotic Content\")}")
}

Apollo router:

  • Version 1.40.1
  • federation v2.3 (defined in schema)
@rickbijkerk rickbijkerk changed the title @requires on field with argument gives weird behaviour Adding a field changes the returned value of another (@requires directive with arguments involved) Apr 24, 2024
@rickbijkerk
Copy link
Author

Updates description after some more testing

@abernix
Copy link
Member

abernix commented May 6, 2024

This appears to be a federation model or query planning consideration more than it is anything Router-specific. If this changes, the Router could consume any updated federation and query planner support for it, but for now I'll transfer this over to the federation repository.

@abernix abernix transferred this issue from apollographql/router May 6, 2024
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

No branches or pull requests

2 participants