Skip to content

Add validation for duplicate lookups.#170

Open
fotoetienne wants to merge 6 commits intographql:mainfrom
fotoetienne:sjs/duplicate-lookup-validation
Open

Add validation for duplicate lookups.#170
fotoetienne wants to merge 6 commits intographql:mainfrom
fotoetienne:sjs/duplicate-lookup-validation

Conversation

@fotoetienne
Copy link
Copy Markdown

Duplicate lookup fields creates ambiguity for the query planner

Duplicate lookup fields creates ambiguity for the query planner
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 13, 2025

Deploy Preview for composite-schemas ready!

Name Link
🔨 Latest commit 88b6525
🔍 Latest deploy log https://app.netlify.com/sites/composite-schemas/deploys/67b3965c8ecdbe00083776e0
😎 Deploy Preview https://deploy-preview-170--composite-schemas.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment thread spec/Section 2 -- Source Schema.md Outdated
fotoetienne and others added 2 commits February 16, 2025 17:10
Co-authored-by: Glen <glen.84@gmail.com>
@andimarek
Copy link
Copy Markdown

I think in order to allow for migration in a non breaking way we should allow deprecated fields. So it should be two or more non-deprecated lookup fields cause an error.

@fotoetienne
Copy link
Copy Markdown
Author

I think in order to allow for migration in a non breaking way we should allow deprecated fields. So it should be two or more non-deprecated lookup fields cause an error.

That's a good idea. So the query planner would always choose the non-deprecated one, making it still unambiguous.

@michaelstaib
Copy link
Copy Markdown
Member

I think in order to allow for migration in a non breaking way we should allow deprecated fields. So it should be two or more non-deprecated lookup fields cause an error.

we could discard of the deprecated lookup in the composition so that the gateway does not need to choose.

@martijnwalraven
Copy link
Copy Markdown

we could discard of the deprecated lookup in the composition so that the gateway does not need to choose.

But that would break existing clients that depend on the deprecated lookup field. So I don't think we want to remove them completely, just enforce that there's always exactly one non-deprecated lookup for composition and query planning to take advantage of.

@fotoetienne
Copy link
Copy Markdown
Author

I think in order to allow for migration in a non breaking way we should allow deprecated fields. So it should be two or more non-deprecated lookup fields cause an error.

On further reflection, I believe migration could also be handled in a non-breaking way without allowing multiple @lookups.

before:

type Query {
    bookById(id: ID!): Book @lookup
}

after:

type Query {
    bookById(id: ID!): Book @deprecated
    bookByIdV2(id: ID!): Book @lookup
}

The subgraph would just move @lookup to the new field while leaving the old field present in the schema but without @lookup directive.

Perhaps for simplicity we can indeed restrict to a single @lookup without hindering migration.

}
```

For a given source schema, there must be exactly one non-deprecated lookup field
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to move this to the validation section.

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