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

Admin UI: big cleanup of query construction #2976

Merged

Conversation

Vultraz
Copy link
Contributor

@Vultraz Vultraz commented May 15, 2020

And now, my big weekend PR.

This refactors the Admin UI's list and item query construction. Instead of using complicated and very hard-to-read string concatenation, this makes use of query variables wherever possible.

  • All queries are now named (prep for another change I have coming)!
  • Changes the item query to a single, static query (since we're always fetching all fields) taking an id argument.
  • List queries now use variables for all input (search, where, skip, first, and sortBy). The new getListQuery function only takes fields to control which fields we're querying since that can't be done via variables. Even better, using variables makes it clear exactly what arguments are accepted and their types.
  • Since where filters are just passed in via variables now, getFilterGraphQL doesn't need to handle messy strings anymore and can just return plain objects!
  • gqlCountQueries was removed and replaced with a helper in Home/index.js.

@changeset-bot
Copy link

changeset-bot bot commented May 15, 2020

🦋 Changeset is good to go

Latest commit: b45573b

We got this.

This PR includes changesets to release 29 packages
Name Type
@keystonejs/app-admin-ui Major
@keystonejs/field-content Major
@keystonejs/fields Major
@keystonejs/fields-mongoid Major
@keystonejs/demo-project-blog Patch
@keystonejs/demo-custom-fields Patch
@keystonejs/demo-project-meetup Patch
@keystonejs/demo-project-todo Patch
@keystonejs/cypress-project-access-control Patch
@keystonejs/cypress-project-basic Patch
@keystonejs/cypress-project-client-validation Patch
@keystonejs/cypress-project-login Patch
@keystonejs/cypress-project-social-login Patch
@keystonejs/example-projects-blank Patch
@keystonejs/example-projects-nuxt Patch
@keystonejs/example-projects-starter Patch
@keystonejs/example-projects-todo Patch
@keystonejs/auth-passport Patch
@keystonejs/auth-password Patch
@keystonejs/fields-authed-relationship Patch
@keystonejs/fields-auto-increment Patch
@keystonejs/fields-datetime-utc Patch
@keystonejs/fields-markdown Patch
@keystonejs/fields-wysiwyg-tinymce Patch
@keystonejs/keystone Patch
@keystonejs/list-plugins Patch
@keystonejs/api-tests Patch
@keystonejs/benchmarks Patch
@keystonejs/adapter-mongoose 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

Copy link
Contributor

@timleslie timleslie left a comment

Choose a reason for hiding this comment

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

This all looks fantastic. The one change to make is that this is actually a major version bump on each package, since the API of getFilterGraphQL has changed from returning a string to an object, which is a breaking change.

@Vultraz
Copy link
Contributor Author

Vultraz commented May 17, 2020

@timleslie done 👍

Copy link
Contributor

@timleslie timleslie left a comment

Choose a reason for hiding this comment

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

Yep, looks good 👍

@timleslie timleslie merged commit ea96083 into keystonejs:master May 18, 2020
@Vultraz Vultraz deleted the admin-ui-refactor-query-generation branch May 18, 2020 00:29
This was referenced May 18, 2020
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.

None yet

2 participants