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

Only coerce items API input when using resolveFields: false #5517

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

timleslie
Copy link
Contributor

@timleslie timleslie commented Apr 22, 2021

The argument coercion applied in the items API should only be done in the code path where we're calling the mutations directly. In the case where we go through the GraphQL API itself we don't want to do this. For most field types it doesn't make a different but for Upload types it will convert an object of the form

    {
      upload: Upload {
        resolve: [Function],
        reject: [Function],
        promise: Promise { [Object] },
        file: {
          createReadStream: [Function: createReadStream],
          filename: 'keystone.jpeg',
          mimetype: 'image/jpeg',
          encoding: 'utf-8'
        }
      }
    }

into

    {
      upload: Promise {
        {
          createReadStream: [Function: createReadStream],
          filename: 'keystone.jpeg',
          mimetype: 'image/jpeg',
          encoding: 'utf-8'
        }
      }
    }

which doesn't work as an input with the graphql() function which we use to execute server side GraphQL

@changeset-bot
Copy link

changeset-bot bot commented Apr 22, 2021

🦋 Changeset detected

Latest commit: a550f75

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/server-side-graphql-client-legacy Patch
@keystone-next/keystone 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 22, 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/BaKrMdjnWbej2toqcRZdHpwHkk3d
✅ Preview: https://keystone-next-docs-git-item-api-coerce-data-keystonejs.vercel.app

@vercel vercel bot temporarily deployed to Preview April 22, 2021 04:56 Inactive
src
}
`,
const data = await context.lists.Test.createOne({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes in this PR allow this test to be re-written with the items API, where previously it would fail.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 22, 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 a550f75:

Sandbox Source
@keystone-next/example-sandbox Configuration

@vercel vercel bot temporarily deployed to Preview April 22, 2021 05:11 Inactive
@vercel vercel bot temporarily deployed to Preview April 22, 2021 05:21 Inactive
@timleslie timleslie requested a review from emmatown April 22, 2021 05:26
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.

I believe this is incorrect, I'm going to look into it more.

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.

I was incorrect, I interpreted this as "stop coercing the inputs completely" when really this is "let the graphql function coerce the inputs"

@timleslie timleslie merged commit a6cdf3d into master Apr 22, 2021
@timleslie timleslie deleted the item-api-coerce-data branch April 22, 2021 05:45
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