Skip to content

Response type missing when called with non const variables #15

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

Open
zhjch05 opened this issue Dec 10, 2024 · 1 comment
Open

Response type missing when called with non const variables #15

zhjch05 opened this issue Dec 10, 2024 · 1 comment

Comments

@zhjch05
Copy link

zhjch05 commented Dec 10, 2024

Hi team, would request a help on debugging the types of response like this code example here:

let cursor: InputMaybe<string> | undefined = undefined;
const response = await admin.graphql(
        `#graphql
          query SyncProducts($cursor: String) {
            products(first: 10, after: $cursor) {
              edges {
                node {
                  id
                  title
                  handle
                  status
                }
                cursor
              }
              pageInfo {
                hasNextPage
              }
            }
          }`,
        {
          variables: {
            cursor,
          },
        },
      );

In the code above I am getting error:

'response' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer

But if I directly use "cursor: undefined" in variables, I don't see any type errors any more (same if I use null). How to correctly infer the response type when using variables like cursor here? Am I mis-use any graphql codegen configs?

@adearriba
Copy link

Same issue here.

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