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

Split default value loop from field-type resolver loop #6119

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

timleslie
Copy link
Contributor

@timleslie timleslie commented Jul 16, 2021

Decouples these two loops so that we can provide better error messages moving forward.

This also lifts the null input case out of the individual relationship resolver functions so we can have the discussion around what the correct behaviour for this input should be (currently a no-op).

@vercel
Copy link

vercel bot commented Jul 16, 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/2NvuW3t2RUkwNs8XLxmUHZzfzynr
✅ Preview: https://keystone-next-docs-git-resolve-data-updates-keystonejs.vercel.app

@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2021

🦋 Changeset detected

Latest commit: 26e3606

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

This PR includes changesets to release 1 package
Name Type
@keystone-next/keystone 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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 16, 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.

@timleslie timleslie changed the title Split default value loop from field-type resolver loop [WIP] Split default value loop from field-type resolver loop Jul 16, 2021
@timleslie timleslie force-pushed the resolve-data-updates branch from de45bca to 26e3606 Compare July 16, 2021 03:02
@vercel vercel bot temporarily deployed to Preview July 16, 2021 03:02 Inactive
@timleslie timleslie changed the title [WIP] Split default value loop from field-type resolver loop Split default value loop from field-type resolver loop Jul 16, 2021
@timleslie timleslie requested a review from a team July 16, 2021 03:10
Comment on lines +186 to +193
if (input === undefined) {
// No-op: This is what we want
return () => undefined;
}
if (input === null) {
// No-op: Should this be UserInputError?
return () => undefined;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being here better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just about visibility. I want to have a single place to point at for this discussion, and it frees up the four other resolvers to be simpler.

Copy link
Member

Choose a reason for hiding this comment

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

Could you not do this or write it in such a way where the value used to decide what to return is based on the value passed to the function rather than the input from GraphQL? The resolve function passed to relationship field input resolvers currently accepts some input that the field's input resolver calls it with and decides what to do based on that rather than using the GraphQL input directly and this breaks that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to bike shed this too much because what I really want is for all this code to evaporate even further, so as long as this works I want to move forward and have these specific lines go away as part of broader changes I'm working on.

@timleslie timleslie merged commit 597edbd into master Jul 16, 2021
@timleslie timleslie deleted the resolve-data-updates branch July 16, 2021 04:12
Nikitoring pushed a commit to Nikitoring/keystone that referenced this pull request Sep 14, 2021
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