Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Contentful Plugin: Should output complete schema regardless of whether content is available #28892

Closed
rshackleton opened this issue Jan 6, 2021 · 7 comments
Labels
topic: source-contentful Related to Gatsby's integration with Contentful type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.

Comments

@rshackleton
Copy link

Description

When content types are created but are not yet populated they do not include any of their fields in the GraphQL schema, this means that we cannot write queries against those fields which will work when the data is available.

This issue would arise if the content was available but subsequently unpublished or deleted.

The content model can be represented in the schema by using the schema customisation API rather than using inference.

Partially discussed here: #1517

Note: I appreciate this is mentioned in the plugin's readme but this is a serious drawback of the plugin.

A similar fix was put in place on the Kentico Kontent source plugin last year:

https://github.com/Kentico/kontent-gatsby-packages/blob/master/packages/gatsby-source-kontent/src/createSchemaCustomization.items.ts

Steps to reproduce

  1. Create a new content model in Contentful.
  2. Setup the source plugin with default settings, space ID and access token.
  3. Run gatsby develop and inspect the schema

Expected result

The schema should include the full model rather than a "skeleton" structure with only the default fields.

Actual result

The type exists but does not include the full model, only the base Contentful fields.

image

image

Environment

  System:
    OS: Windows 10 10.0.19041
    CPU: (12) x64 Intel(R) Core(TM) i7-5930K CPU @ 3.50GHz
  Binaries:
    Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 87.0.4280.88
    Edge: Spartan (44.19041.423.0), Chromium (87.0.664.66)
  npmPackages:
    gatsby: ^2.26.1 => 2.29.3 
    gatsby-image: ^2.5.0 => 2.8.0 
    gatsby-plugin-alias-imports: ^1.0.5 => 1.0.5 
    gatsby-plugin-layout: ^1.7.0 => 1.7.0 
    gatsby-plugin-manifest: ^2.6.1 => 2.9.1 
    gatsby-plugin-offline: ^3.4.0 => 3.7.1 
    gatsby-plugin-react-helmet: ^3.4.0 => 3.7.0 
    gatsby-plugin-sass: ^2.8.0 => 2.8.0 
    gatsby-plugin-sharp: ^2.8.0 => 2.11.2 
    gatsby-source-contentful: ^4.3.1 => 4.3.1 
    gatsby-source-filesystem: ^2.5.0 => 2.8.1 
    gatsby-transformer-sharp: ^2.6.0 => 2.9.0 
@rshackleton rshackleton added the type: bug An issue or pull request relating to a bug in Gatsby label Jan 6, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 6, 2021
@rshackleton
Copy link
Author

rshackleton commented Jan 6, 2021

The code that needs to be updated should begin here:

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-contentful/src/gatsby-node.js#L347

The types are being generated but the fields are not explicitly defined.

The following breakdown of field types in Contentful can be used to determine the appropriate GraphQL type.

https://www.contentful.com/developers/docs/concepts/data-model/

Reference field types should be either ContentfulEntry or ContentfulReference if singular or an array of those if a collection.

This would allow the underlying data to be queried using inline fragments.

@LekoArts LekoArts added topic: source-contentful Related to Gatsby's integration with Contentful type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby labels Jan 7, 2021
@LekoArts
Copy link
Contributor

LekoArts commented Jan 7, 2021

Sounds like it's the same as #12816 ?

@rshackleton
Copy link
Author

rshackleton commented Jan 7, 2021

@LekoArts thanks for finding this, I was searching for open issues but couldn't find any.

Happy to see some progress has been made on this but it is very disheartening to see that PR has been open for over 6 months. 😫

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 27, 2021
@rshackleton
Copy link
Author

Definitely not stale, or shouldn't be...

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 28, 2021
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 17, 2021
@rshackleton
Copy link
Author

Nope, not stale.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 24, 2021
@LekoArts LekoArts closed this as completed Mar 1, 2021
@gatsbyjs gatsbyjs locked and limited conversation to collaborators Mar 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
topic: source-contentful Related to Gatsby's integration with Contentful type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants