question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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: https://github.com/gatsbyjs/gatsby/issues/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 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rshackletoncommented, Jan 27, 2021

Definitely not stale, or shouldn’t be…

0reactions
rshackletoncommented, Feb 23, 2021

Nope, not stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contentful Plugin: Should output complete schema regardless ...
This issue would arise if the content was available but subsequently unpublished or deleted. The content model can be represented in the schema...
Read more >
GraphQL Content API - Contentful
The GraphQL API gives you the control to choose whether you want to access published or non-published content in a very granular fashion....
Read more >
gatsby-source-wordpress
gatsby-source-wordpress Source plugin for pulling data into Gatsby from WordPress sites using the WordPress REST API. An example site for…
Read more >
Customizing Gatsby / Contentful Schema - graphql
If I do have the customization in place, then the output for this query is null - regardless of whether the content is...
Read more >
Gatsby Changelog | 5.3.0
Gatsby printed the complete contents of the page data to the terminal. ... But since this also included the GraphQL results those logs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found