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

[executor-http] Infer whether variables are optional or not #5054

Open
Tracked by #5201 ...
n1ru4l opened this issue Feb 13, 2023 · 0 comments
Open
Tracked by #5201 ...

[executor-http] Infer whether variables are optional or not #5054

n1ru4l opened this issue Feb 13, 2023 · 0 comments

Comments

@n1ru4l
Copy link
Collaborator

n1ru4l commented Feb 13, 2023

For the given GraphQL executable document:

const AllFilmsWithVariablesQuery = graphql(/* GraphQL */ `
  query allFilmsWithVariablesQuery($first: Int!) {
    allFilms(first: $first) {
      edges {
        node {
          ...FilmItem
        }
      }
    }
  }
`);

The following does not result in a TypeScript error:

executor({
  document: AllFilmsWithVariablesQuery,
})

As one of the variables is declared as non-nullable the value must be provided. This can be implemented like the following:
https://github.com/dotansimha/graphql-code-generator/blob/676063c1e62017398deeb580278448935a0da3df/examples/typescript-esm/src/executeOperation.ts#L8-L9

graphql-request in comparison handles this case and behaves as expected, yielding a better DX.

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

1 participant