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

the resolve function only querying __typename on fields that don't have a input #2189

Open
brummetj opened this issue Mar 5, 2025 · 1 comment

Comments

@brummetj
Copy link

brummetj commented Mar 5, 2025

Description

hello! I'm following your docs on using the resolve function for our nextJS app. I'm running the query

    const data = await resolve(
        ({
             query: {
                 me: {
                   users: {
                     firstName,
                     lastName,
                 }
               },
             },
         }) => {},
        {
            extensions: {
            }
        }
    );

my GQL schema looks like


type User {
    firstName: String!
    lastName: String!
}
type Users {
    users: [User]
}

extend type Query {
    me: Users
}

when I execute the query if I print the query string in the queryFetcher it only asks for the type name in the query string. and I'm only getting the type name back

query{me{__typename}}"

what am I missing here?

@vicary
Copy link
Member

vicary commented Mar 7, 2025

Array fields needs to be treated like an array, TypeScript may help noticing the issue.

const data = await resolve(
  ({
    query: {
      me: {
        users: [
          { firstName, lastName }
            = {} // Default value in case of empty arrays
        ],
      },
    },
  }) => {}
);

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