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

Variables are not strictly typed #10659

Closed
jhalborg opened this issue Mar 16, 2023 · 2 comments
Closed

Variables are not strictly typed #10659

jhalborg opened this issue Mar 16, 2023 · 2 comments

Comments

@jhalborg
Copy link

Issue Description

Give the query

export const GET_ROCKET_INVENTORY = gql(/* GraphQL */ `
  query FilmById($id: ID!) {
    film(id: $id) {
      title
    }
  }
`);

the following type is generated:
image

It correctly validates that id must be a variable of type String
image

and that it is requried
image

but it allows for random arguments to be passed
image

I would expect an error for variables that are unused in the query.

Link to Reproduction

https://codesandbox.io/p/sandbox/pedantic-dream-0x7z92?file=%2Fsrc%2FApp.tsx

Reproduction Steps

Run the example, and see that you get no Typescript errors for the invalid variable in renderQuery.tsx

@phryneas
Copy link
Member

phryneas commented Mar 16, 2023

Hey there, thanks for the report!

We already have a merged PR for this: #10506

In version 3.8, this behavior will be as you expect - we didn't want to introduce it in 3.7 as it changes the behavior a bit too much for a "patch"!

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants