gatsby: Gatsby Schema Customization API fails with gatsby-source-contentful and union types
Description
The new schema API always returns null on fields that reference multiple union types in Contentful when at least one of the types is not present.
I’m not sure if this is only affecting arrays of unions or single unions too.
in this instance the subSections
field is not referencing any of the ContentfulSubSectionSibling
union type
Steps to reproduce
clone: git clone https://github.com/sami616/gatsby-contentful-custom-schema-bug.git yarn install yarn start
Expected result
A list should render under the heading Section one
Actual result
My error message renders due to the subSections
being null
Environment
System: OS: macOS 10.14 CPU: x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 10.10.0 - ~/.nvm/versions/node/v10.10.0/bin/node Yarn: 1.13.0 - ~/.nvm/versions/node/v10.10.0/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.10.0/bin/npm Browsers: Chrome: 73.0.3683.86 Firefox: 62.0.3 Safari: 12.0 npmPackages: gatsby: ^2.2.10 => 2.2.10 gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0 gatsby-source-contentful: ^2.0.42 => 2.0.42 gatsby-transformer-remark: ^2.1.7 => 2.1.7 npmGlobalPackages: gatsby-cli: 2.4.3
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (10 by maintainers)
With gatsby v2.5 the following should now work:
Hey @stefanprobst I have something similar to what you wrote, but now gatsby says:
Querying GraphQLUnion types is not supported.
Did I miss something? Does it work if I write a custom resolver for it?I’m closing this as it should be fixed - feel free to open if there are still issues. Thanks
Thanks @freiksenet - i just ran a small test and attached 2 out of 3 possible content types onto a field (instead of one like in my example) and it still failed - should gatsby at this point not know this should be a union?
ps - thank you for the example, attaching a manual resolver does seem to work
cc @freiksenet @stefanprobst
#12272