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

Use the GraphQL API for lists.<list>.count #5552

Merged
merged 1 commit into from
Apr 26, 2021
Merged

Conversation

timleslie
Copy link
Contributor

This makes the .count() method consistent with the rest of the API, which execute GraphQL queries via context.graphql.run to get their results.

@changeset-bot
Copy link

changeset-bot bot commented Apr 26, 2021

🦋 Changeset detected

Latest commit: 55444ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@keystone-next/keystone Patch
@keystone-next/adapter-prisma-legacy Patch
@keystone-next/test-utils-legacy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Apr 26, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/4c3yQGwsYa2oaUrYwkK1zkgxxh9D
✅ Preview: https://keystone-next-docs-git-graphql-run-count-keystonejs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 26, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 55444ce:

Sandbox Source
@keystone-next/example-sandbox Configuration

@vercel vercel bot temporarily deployed to Preview April 26, 2021 22:49 Inactive
@timleslie timleslie requested a review from a team April 26, 2021 22:57
Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

Don't conditionally add the variables to the graphql query, if the variable values are null or undefined, graphql will handle it

@timleslie
Copy link
Contributor Author

Don't conditionally add the variables to the graphql query, if the variable values are null or undefined, graphql will handle it

See, that's what I thought, but in practice it barfed out, so I had to add this big pile of conditionals :-(

@emmatown
Copy link
Member

What was the error?

@timleslie
Copy link
Contributor Author

It complained about not being able to pass undefined to a field of type Int!. I'll see if I can recreate it.

@emmatown
Copy link
Member

You should make the type in the variable Int, not Int! then

@timleslie
Copy link
Contributor Author

  console.log
    {
      query: 'query ($first: Int!, $skip: Int!, $where: UserWhereInput) { _allUsersMeta(first: $first, skip: $skip, where: $where) { count }  }',
      variables: { first: undefined, skip: undefined, where: undefined }
    }

    GraphQLError: Variable "$first" got invalid value undefined; Expected non-nullable type "Int!" not to be null.

@vercel vercel bot temporarily deployed to Preview April 26, 2021 23:16 Inactive
@timleslie
Copy link
Contributor Author

🤦 I'm glad someone's awake this morning.

@vercel vercel bot temporarily deployed to Preview April 26, 2021 23:42 Inactive
@timleslie timleslie requested a review from emmatown April 26, 2021 23:46
@timleslie timleslie enabled auto-merge (squash) April 26, 2021 23:48
@timleslie timleslie merged commit a0c5aa3 into master Apr 26, 2021
@timleslie timleslie deleted the graphql-run-count branch April 26, 2021 23:56
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.

2 participants