payload icon indicating copy to clipboard operation
payload copied to clipboard

more type accurate arrays in the GraphQL schema

Open chaoky opened this issue 2 years ago • 3 comments

Description

as discussed in https://github.com/payloadcms/payload/discussions/764

{
  slug: "landing",
  fields: [
    {
      name: "cards",
      type: "blocks",
      blocks: [cards],
      required: true,
    },
  ],
}

is outputting

type Landing {
  cards: [Landing_Cards]
}

instead of

type Foo {
  cards: [Landing_Cards!]!
}
  • [x] I have read and understand the CONTRIBUTING.md document in this repository

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

Checklist:

  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] Existing test suite passes locally with my changes
  • [ ] I have made corresponding changes to the documentation

chaoky avatar Jul 22 '22 21:07 chaoky

should I just make the union type always non-nullable? is there a case where [null] will be returned?

chaoky avatar Jul 22 '22 21:07 chaoky

Hey @chaoky — good question! There will never be a case where [null] will be returned, so yes, you can make the union type always non-nullable.

Thank you!

jmikrut avatar Jul 27 '22 19:07 jmikrut

I made every list element non nil, I honestly think that this should be the default in GraphQL, who's is returning [null]?

chaoky avatar Jul 27 '22 21:07 chaoky

Merged! Thank you @chaoky!!!

jmikrut avatar Aug 16 '22 02:08 jmikrut