Giter VIP home page Giter VIP logo

gatsby-source-datocms's Issues

TypeError: Cannot read property 'internal' of null

Getting an error when running gatsby develop

node 8.94
yarn 1.3.2

Ran the gatsby new command and added the gatsby-source-datocms plugin. Filled out the files in gatsby-config.js and getting this when running gatsby develop

image

Am i missing something?

I've just encountered the same thing after cloning the gatsby-portfolio code and adding the datocms api key

html attributes returns null in multiple paragraph text field

Issue Description

Querying the html of a multiple paragraph text such as in the code block below doesn't work the same way for all the editors that can be set in the field setting in the presentation tab.

{
  allDatoCmsBlogPost {
    edges {
      node {
        excerptNode {
          childMarkdownRemark {
            html
            timeToRead
          }
        }
      }
    }
  }
}

I'm quite confused by the two different GraphQL syntax existing with DatoCMS i.e. the one usable in GraphiQL console and the one from the gatsby-source-datocms plugin. The default one is much more transparent I find...

FetchError: invalid json response body

Just tried to update to the newly updated plugin. Got the following error after running:
yarn upgrade gatsby-source-datocms && rm -rf node_modules && yarn install && rm -rf .cache && yarn develop

error Plugin gatsby-source-datocms returned an error


  FetchError: invalid json response body at https://site-api.datocms.com/items?version=published&page%5Blimit%5D=100 reason: Unexpected token < i  n JSON at position 0
  
  - body.js:48 
    [wfa-gatsby]/[node-fetch]/lib/body.js:48:31
  
  - util.js:16 tryCatcher
    [wfa-gatsby]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [wfa-gatsby]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [wfa-gatsby]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [wfa-gatsby]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:694 Promise._settlePromises
    [wfa-gatsby]/[bluebird]/js/release/promise.js:694:18
  
  - async.js:138 _drainQueueStep
    [wfa-gatsby]/[bluebird]/js/release/async.js:138:12
  
  - async.js:131 _drainQueue
    [wfa-gatsby]/[bluebird]/js/release/async.js:131:9
  
  - async.js:147 Async._drainQueues
    [wfa-gatsby]/[bluebird]/js/release/async.js:147:5
  
  - async.js:17 Immediate.Async.drainQueues
    [wfa-gatsby]/[bluebird]/js/release/async.js:17:14
  

warning The gatsby-source-datocms plugin has generated no Gatsby nodes. Do you need it?

Querying Multiple file fields DatoCMS and Gatsby

Hi I am trying to query a multiple file field inside a collection it's a series of images and the result will be an image gallery. I have tried all manner of queries to make this happen but cant seem to query the images. Here is where I am at with my code.

My query is

`export const query = graphql`
  query AccomPageQuery($slug: String!) {
    datoCmsAccomodationPage(slug: { eq: $slug }) {
          mainHeading
          mainText
          subHeading
          headerImage {
            fluid(maxWidth: 600, imgixParams: { fm: "jpg", auto: "compress" }) {
              ...GatsbyDatoCmsFluid
            }   
          }
          imageGallery { // THIS IS MY GALLERY
            fluid {
              src
            }
          }
    }
  }`

I then try and pull this data like this for example (note I know the below will not yield an image. Im just trying to display any data at the moment relating to the image array)

{data.datoCmsAccomodationPage.imageGallery.map(({ fluid }, index) =>
          <Col key={index} md="6" sm="12" className="mb-4">
          <p className="px-3">{fluid.src}</p>
          </Col>

The result is

←→1 of 3 errors on the page
TypeError: Cannot read property 'fluid' of null

Any help would be appreciated. This is doing my head in. I will be happy to write it up and add it to your docs when done

Major Issue: build(...).toMap is not a function

Not sure what's happening, but when running gatsby develop I now get the following error:

bug

I just tried creating a new project from scratch and the error is still there.
This seems to be linked to models that have an image field.

Upgrading to 1.1.9 breaks Gatsby v1 projects

Hi there

After the package upgrade I get this error message:

GraphQL Error Unknown type "DatoCmsFixed". Did you mean "DatoCmsField", "DatoCmsSite", "DatoCmsSizes", "DatoCmsVideo", or "DatoCmsAsset"?
[0]
[0] file: /Users/--/Development/asdf/.cache/fragments/datocms-asset-fragments.js
[0]
[0] 1 |
[0] > 2 | fragment GatsbyDatoCmsFixed on DatoCmsFixed {
[0] | ^
[0] 3 | base64
[0] 4 | width
[0] 5 | height
[0] 6 | src
[0] 7 | srcSet
[0] 8 | }

In the meantime I fixed the version to 1.1.8 in my package.json. Thank you!

Cheers,
Christoph

No favicon in Dato results in build error

Hi, I didn't have any favicon uploaded to Dato in my global site settings and got this error when running gatsby develop.

  Invariant Violation: GraphQLParser: Unknown field `rel` on type `attributes_4`. Source: document `GatsbyDatoCmsFaviconMetaTags` file: `GraphQL request`.

I can upload a favicon to resolve this issue, but thought I'd point it out regardless as people who are new to Gatsby, Dato or this plugin might have trouble with this.

Modular block single link fields of multiple possible types not querying properly.

We are trying to query a model that has a modular block field called items. Each item has a field called locatable. The locatable is a single link that can be one of many types. When querying with the dato api, it works just fine. When querying with the gatsby graphql api, it is unable to handle the multiple types on the locatable. It just chooses one datatype and expects all of them to be of that type.
"gatsby-source-datocms": "^2.1.3"

Screen Shot 2019-04-25 at 4 45 34 PM
Screen Shot 2019-04-25 at 4 46 20 PM

conflicting field types in field types

I've got 2 separate content models that use default values. When using gatsby i'm getting the following

`warning There are conflicting field types in your data. GraphQL schema will omit those fields.
DatoCmsField.defaultValue:
 - type: boolean
   value: false
 - type: string`

TypeError: Cannot read property 'replace' of undefined and Error: DatoCmsAsset.fluid provided incorrect OutputType: '"DatoCmsFluid"'

Hi, this may be related to #48 but I'm still experiencing issues building. I've ensured that I'm running the latest versions of Gatsby and the plugin.

When running gatsby develop, I get the following:

$ gatsby develop
success open and validate gatsby-configs — 0.013 s
success load plugins — 1.059 s
success onPreInit — 0.003 s
success initialize cache — 0.011 s
success copy gatsby files — 0.041 s
success onPreBootstrap — 0.006 s
success loading DatoCMS content — 2.594 s
error gatsby-node.js returned an error


  TypeError: Cannot read property 'replace' of undefined
  
  - index.js:10 module.exports
    [acore-gatsby]/[gatsby-source-filesystem]/[slash]/index.js:10:13
  
  - create-file-path.js:39 module.exports
    [acore-gatsby]/[gatsby-source-filesystem]/create-file-path.js:39:61
  
  - gatsby-node.js:86 Object.exports.onCreateNode
    /Users/ernie/projects/acore-gatsby/gatsby-node.js:86:19
  
  - api-runner-node.js:212 runAPI
    [acore-gatsby]/[gatsby]/dist/utils/api-runner-node.js:212:37
  
  - api-runner-node.js:335 resolve
    [acore-gatsby]/[gatsby]/dist/utils/api-runner-node.js:335:19
  
  - debuggability.js:313 Promise._execute
    [acore-gatsby]/[bluebird]/js/release/debuggability.js:313:9
  
  - promise.js:483 Promise._resolveFromExecutor
    [acore-gatsby]/[bluebird]/js/release/promise.js:483:18
  
  - promise.js:79 new Promise
    [acore-gatsby]/[bluebird]/js/release/promise.js:79:10
  
  - api-runner-node.js:334 Promise.mapSeries.plugin
    [acore-gatsby]/[gatsby]/dist/utils/api-runner-node.js:334:16
  
  - util.js:16 tryCatcher
    [acore-gatsby]/[bluebird]/js/release/util.js:16:23
  
  - reduce.js:155 Object.gotValue
    [acore-gatsby]/[bluebird]/js/release/reduce.js:155:18
  
  - reduce.js:144 Object.gotAccum
    [acore-gatsby]/[bluebird]/js/release/reduce.js:144:25
  
  - util.js:16 Object.tryCatcher
    [acore-gatsby]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [acore-gatsby]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [acore-gatsby]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [acore-gatsby]/[bluebird]/js/release/promise.js:614:10

I cloned the plugin source to attempt to debug, and I also received the following error in addition to the one above (this appears directly after output above):

success source and transform nodes — 2.699 s
error UNHANDLED REJECTION


  Error: DatoCmsAsset.fluid provided incorrect OutputType: '"DatoCmsFluid"'
  
  - TypeMapper.js:282 TypeMapper.convertOutputFieldConfig
    [acore-gatsby]/[graphql-compose]/lib/TypeMapper.js:282:15
  
  - configAsThunk.js:18 resolveOutputConfigAsThunk
    [acore-gatsby]/[graphql-compose]/lib/utils/configAsThunk.js:18:41
  
  - ObjectTypeComposer.js:284 ObjectTypeComposer.getFieldConfig
    [acore-gatsby]/[graphql-compose]/lib/ObjectTypeComposer.js:284:58
  
  - toInputObjectType.js:44 fieldNames.forEach.fieldName
    [acore-gatsby]/[graphql-compose]/lib/utils/toInputObjectType.js:44:19
  
  - Array.forEach
  
  - toInputObjectType.js:38 toInputObjectType
    [acore-gatsby]/[graphql-compose]/lib/utils/toInputObjectType.js:38:14
  
  - toInputObjectType.js:78 convertInputObjectField
    [acore-gatsby]/[graphql-compose]/lib/utils/toInputObjectType.js:78:19
  
  - toInputObjectType.js:45 fieldNames.forEach.fieldName
    [acore-gatsby]/[graphql-compose]/lib/utils/toInputObjectType.js:45:23
  
  - Array.forEach
  
  - toInputObjectType.js:38 toInputObjectType
    [acore-gatsby]/[graphql-compose]/lib/utils/toInputObjectType.js:38:14
  
  - ObjectTypeComposer.js:493 ObjectTypeComposer.getInputTypeComposer
    [acore-gatsby]/[graphql-compose]/lib/ObjectTypeComposer.js:493:84
  
  - sort.js:38 getSortInput
    [acore-gatsby]/[gatsby]/dist/schema/types/sort.js:38:42
  
  - schema.js:552 addResolvers
    [acore-gatsby]/[gatsby]/dist/schema/schema.js:552:23
  
  - schema.js:188 
    [acore-gatsby]/[gatsby]/dist/schema/schema.js:188:13
  
  - Generator.next
  

TypeError: Cannot read property 'type' of undefined

Was just halfway through developing a site with this plugin, and it suddenly threw this error at me.
I had just created a new modular content type in Dato, and had restarted gatsby develop to pull the new content through. I hadn't added a query for it in Gatsby yet, and the new type did already have some content in it, so it was not empty.

I had already created an earlier different modular content type in Dato, and all worked fine until I added this new one.

$ gatsby develop --https
info setting up automatic SSL certificate (may require sudo)

success open and validate gatsby-config — 0.029 s
success onPreBootstrap — 1.578 s
success delete html and css files from previous builds — 0.086 s
success copy gatsby files — 0.493 s
error Plugin gatsby-source-datocms returned an error


  TypeError: Cannot read property 'type' of undefined

  - makeType.js:9 module.exports
    [cirruscreative]/[gatsby-source-datocms]/makeType.js:9:14

  - makeId.js:8 makeId
    [cirruscreative]/[gatsby-source-datocms]/makeId.js:8:12

  - createItemNodes.js:26 itemNodeId
    [cirruscreative]/[gatsby-source-datocms]/createItemNodes.js:26:10

  - createItemNodes.js:64
    [cirruscreative]/[gatsby-source-datocms]/createItemNodes.js:64:45

  - Array.forEach

  - createItemNodes.js:46
    [cirruscreative]/[gatsby-source-datocms]/createItemNodes.js:46:28

  - Array.forEach

  - createItemNodes.js:40
    [cirruscreative]/[gatsby-source-datocms]/createItemNodes.js:40:11

  - Array.forEach

  - createItemNodes.js:37 createItemNodes
    [cirruscreative]/[gatsby-source-datocms]/createItemNodes.js:37:26

  - gatsby-node.js:77 _callee$
    [cirruscreative]/[gatsby-source-datocms]/gatsby-node.js:77:25

  - gatsby-node.js:3 step
    [cirruscreative]/[gatsby-source-datocms]/gatsby-node.js:3:191

  - gatsby-node.js:3
    [cirruscreative]/[gatsby-source-datocms]/gatsby-node.js:3:361


⠐ source and transform nodes

I have tried deleting .cache and also tried removing the new content type from Dato, but it still throws this error.

Any ideas?

Union types don't work

I have a type Page which has a field content which links to various other types like Post, Recipe, NavPage etc. The native DatoCMS GraphQL API works OK, but the one generated by gatsby-source-datocms does not, it throws errors such as Expected value of type \"DatoCmsNavPage\" but got: [object Object]. when querying for some sub-properties of content.

Is this supposed to work or is this a feature which could be added?

I am now blocked with content modeling with DatoCMS and Gatsby as it appears that these 3 features are missing:

Page content model:

screen shot 2018-10-07 at 14 26 04

DatoCMS GraphQL API, works OK:

screen shot 2018-10-07 at 14 27 24

Gatsby GraphQL API, doesn't work:

screen shot 2018-10-07 at 14 25 02

[v2] TypeError: EntitiesRepo is not a constructor

I tried setting up a vanilla Gatsby v2 instance this morning and I'm getting stuck right after the configuration.

Using version gatsby-source-datocms @ 2.0.0-alpha.2 and datocms-client @ 0.5.7 (tried 0.6.0 as well)

This is the error:

success open and validate gatsby-config — 0.012 s
success load plugins — 0.255 s
success onPreInit — 0.652 s
success delete html and css files from previous builds — 0.009 s
success initialize cache — 0.017 s
success copy gatsby files — 0.044 s
success onPreBootstrap — 0.001 s
error Plugin gatsby-source-datocms returned an error


  TypeError: EntitiesRepo is not a constructor

  - fetch.js:14
    [Web]/[gatsby-source-datocms]/fetch.js:14:12

  - next_tick.js:61 process._tickCallback
    internal/process/next_tick.js:61:11


error UNHANDLED REJECTION


  TypeError: Cannot read property 'filter' of undefined

  - api-runner-node.js:257 Promise.mapSeries.catch.then.results
    [Web]/[gatsby]/dist/utils/api-runner-node.js:257:42

  - util.js:16 tryCatcher
    [Web]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [Web]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [Web]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [Web]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [Web]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [Web]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [Web]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [Web]/[bluebird]/js/release/async.js:17:14

What I tracked it down to is that the default exports from datocms-client need an extra .default argument as default isn't not automatically resolved.
I found some notes that Babel now doesn't automatically access the default property anymore. Even trying to set output.libraryExport in the Webpack config override didn't do the trick.

Deep filtering doesn't work

Let's say I have a type Post which has a property category of type PostCategory, which itself has a property seo of type SEO. Currently it is not possible to filter by an SEO property, e.g. allDatoCmsPost(filter: { category: { seo: { title: { eq: "my-title" } } } }).

The reason that in this example I offload various properties of the PostCategory model onto a separate SEO model is because there's currently no GraphQL interface type available (see datocms/product-roadmap#95) and I don't want to replicate all my SEO properties across all objects. And I can't use _seoMetaTags because they don't seem to share a common type definition either.

SCRIPT1003: Expected ':'

Hi

After building my Gatsby site I get this error

SCRIPT1003: Expected ':'

in IE 11 on this line

const HelmetDatoCms = ({ seo, favicon }) => {

video_3

Hi

I'm wondering why images from DatoCms in GraphQL are type DatoCmsAsset but videos are video_1, video_2 etc...
Shouldn't they be DatoCmsVideo or at least DatoCmsAsset?

Unknown type "DatoCmsResolutions"

Hello,

Unfortunately, I haven't had any luck getting this gatsby-source to work with Gatsby.

Everything spins up smoothly gatsby develop until I hit this error:

GraphQL Error Unknown type "DatoCmsResolutions". Did you mean "DatoCmsSeoMetaTags", "DatoCmsSiteConnection", "DatoCmsFieldConnection", or "DatoCmsModelConnection"?

  file: /Users/zac/Documents/Dev/datocms-poc-site/.cache/fragments/datocms-seometatags-fragments.js

  1 |
> 2 |   fragment GatsbyDatoCmsResolutions on DatoCmsResolutions {
    |                                        ^
  3 |     base64
  4 |     width
  5 |     height
  6 |     src
  7 |     srcSet
  8 |   }
  9 |

It doesn't crash the develop script, but the data prop is no longer being passed to any of my components. Granted I'm not entirely not sure if this error is what's causing that to happen.

I can still browse all the other available types in GraphiQL, but that's about it.

I tried poking around to find a possible culprit - looks like there were some recent changes to createItemNodes.js? Perhaps there's an issue there... 🤔

Fetch all the localized values for a field

I'm trying to make use of the _all<FieldName>Locales property which was recently introduced and announced in this post:
https://www.datocms.com/changelog/fetch-all-the-language-values-for-a-field-in-a-sing/

The field is available on the DatoCMS GraphQL API, e.g. I have a type called Posts and I can query allPosts { _allSlugLocales { value } }, but as discussed with @stefanoverna gatsby-source-datocms needs to be updated to expose this too.

I need this to implement a language switcher which preserves the location on the website (paths are based on localized slugs).

Changing DatoCMS schema results in errors on gatsby develop

This can be fixed by changing the apiUrl to anything else, running gatsby develop then changing it back.

Many iterations of the error: Calling "touchNode" with a nodeId is deprecated. Please pass an object containing a nodeId instead: touchNode({ nodeId: 'a-node-id' }) and

"touchNode" was called by gatsby-source-datocms
Calling "deleteNode" with a nodeId is deprecated. Please pass an object containing a full node instead: deleteNode({ node })
error UNHANDLED REJECTION


  TypeError: Cannot read property 'children' of undefined

  - actions.js:48 children.concat.children.map.child
    [theia]/[gatsby]/dist/redux/actions.js:48:39

  - Array.map

  - actions.js:47 findChildrenRecursively
    [theia]/[gatsby]/dist/redux/actions.js:47:42

  - actions.js:308 actions.deleteNode.args
    [theia]/[gatsby]/dist/redux/actions.js:308:29

  - bindActionCreators.js:7
    [theia]/[redux]/lib/bindActionCreators.js:7:35

  - api-runner-node.js:45 doubleBoundActionCreators.(anonymous function).args
    [theia]/[gatsby]/dist/utils/api-runner-node.js:45:13

  - gatsby-node.js:85
    [theia]/[gatsby-source-datocms]/gatsby-node.js:85:31

  - Array.forEach

  - gatsby-node.js:81 _callee$
    [theia]/[gatsby-source-datocms]/gatsby-node.js:81:38

  - gatsby-node.js:3 step
    [theia]/[gatsby-source-datocms]/gatsby-node.js:3:191

  - gatsby-node.js:3
    [theia]/[gatsby-source-datocms]/gatsby-node.js:3:361

  - next_tick.js:131 _combinedTickCallback
    internal/process/next_tick.js:131:7

  - next_tick.js:180 process._tickCallback
    internal/process/next_tick.js:180:9```

Replacement for inlineSvg?

It looks like as of 2.1, you've removed support for the inlineSvg attribute. The release blog post mentions that you were wanting to maintain backwards compatibility, but there doesn't seem to be a quick replacement for this feature.

Do you have a recommendation on how we should work with SVG images moving forward?

Cannot run develop

"gatsby-source-datocms": "^2.1.4",

When including:

{
  resolve: `gatsby-source-datocms`,
  options: {
    apiToken: `################`
  }
}

I get

error UNHANDLED REJECTION


  Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer

  - read-wasm.js:8 readWasm
    [ldi.global]/[react-hot-loader]/[source-map]/lib/read-wasm.js:8:13

  - wasm.js:25 wasm
    [ldi.global]/[react-hot-loader]/[source-map]/lib/wasm.js:25:16

  - source-map-consumer.js:264 BasicSourceMapConsumer.then.that
    [ldi.global]/[react-hot-loader]/[source-map]/lib/source-map-consumer.js:264:14

when trying to run gatsby develop.

Not including it will compile successfully.

Deploy with Netlify Issue

I have a Gatsby project, with Dato CMS here

I can build this locally, and with GItlab Pages, absolutely fine. But when I try to build with Netlify, it throws this error:

1:23:23 PM: error UNHANDLED EXCEPTION
1:23:23 PM: 

  Error: /opt/build/repo/node_modules/gatsby-source-datocms/gatsby-node.js:12
  exports.sourceNodes = async ({ boundActionCreators, getNodes, hasNodeChanged,   store, reporter }, { apiToken }) => {
                              ^
  SyntaxError: Unexpected token (
  
  - v8-compile-cache.js:226 NativeCompileCache._moduleCompile
    [repo]/[v8-compile-cache]/v8-compile-cache.js:226:18
  
  - v8-compile-cache.js:172 Module._compile
    [repo]/[v8-compile-cache]/v8-compile-cache.js:172:36
  
  - module.js:20 require
    internal/module.js:20:19
  
  - api-runner-node.js:82 runAPI
    [repo]/[gatsby]/dist/utils/api-runner-node.js:82:20
  
  - api-runner-node.js:178 
    [repo]/[gatsby]/dist/utils/api-runner-node.js:178:33
  
  - map.js:27 
    [repo]/[async]/internal/map.js:27:9
  
  - eachOfLimit.js:64 replenish
    [repo]/[async]/internal/eachOfLimit.js:64:17
  
  - eachOfLimit.js:49 iterateeCallback
    [repo]/[async]/internal/eachOfLimit.js:49:17
  
  - onlyOnce.js:12 
    [repo]/[async]/internal/onlyOnce.js:12:16
  
  - map.js:29 
    [repo]/[async]/internal/map.js:29:13
  
  - util.js:16 tryCatcher
    [repo]/[bluebird]/js/release/util.js:16:23

Any ideas?

TypeError: Site is not a constructor

I get this error with a vanilla gatsby project, using the latest version of this plugin.

error Plugin gatsby-source-datocms returned an error
  TypeError: Site is not a constructor
  - createSiteNode.js:15 module.exports
    [gatsby-source-datocms]/createSiteNode.js:15:14

if I dig into createSiteNode.js the variable Site (used on line 15) is undefined. Both siteEntity and itemsRepo used in the constructor seem to be correct.

Is this an issue with datocms-client or this packages usage of it?

Tree-like collections

Following the example, my schema doesn't have treeChildren and I cannot get my tree children.

Is this example still applicable?

Error: DatoCmsAsset.resolutions provided incorrect OutputType: 'DatoCmsFixed'

Hey there,
I do not know if DataCMS updated there API, but my already running project began to fail building with a weird error log, somehow related to the field mapping of DatoCms Asset.
Could you please assist here?

gatsby develop
success open and validate gatsby-configs — 0.013 s
success load plugins — 0.412 s
success onPreInit — 0.005 s
success initialize cache — 0.007 s
success copy gatsby files — 0.086 s
success onPreBootstrap — 0.011 s
success source and transform nodes — 1.654 s
error UNHANDLED REJECTION


  Error: DatoCmsAsset.resolutions provided incorrect OutputType: 'DatoCmsFixed'
  
  - TypeMapper.js:276 TypeMapper.convertOutputFieldConfig
    [app-website]/[graphql-compose]/lib/TypeMapper.js:276:15
  
  - configAsThunk.js:19 resolveOutputConfigAsThunk
    [app-website]/[graphql-compose]/lib/utils/configAsThunk.js:19:41
  
  - ObjectTypeComposer.js:300 ObjectTypeComposer.getFieldConfig
    [app-website]/[graphql-compose]/lib/ObjectTypeComposer.js:300:58
  
  - toInputObjectType.js:44 fieldNames.forEach.fieldName
    [app-website]/[graphql-compose]/lib/utils/toInputObjectType.js:44:19
  
  - Array.forEach
  
  - toInputObjectType.js:38 toInputObjectType
    [app-website]/[graphql-compose]/lib/utils/toInputObjectType.js:38:14
  
  - ObjectTypeComposer.js:581 ObjectTypeComposer.getInputTypeComposer
    [app-website]/[graphql-compose]/lib/ObjectTypeComposer.js:581:84
  
  - sort.js:38 getSortInput
    [app-website]/[gatsby]/dist/schema/types/sort.js:38:42
  
  - schema.js:552 addResolvers
    [app-website]/[gatsby]/dist/schema/schema.js:552:23
  
  - schema.js:188 
    [app-website]/[gatsby]/dist/schema/schema.js:188:13
  
  - Generator.next
  

error Command failed with exit code 1.

[v2] String fields disappear from schema when published with null values

I have a single-instance model (Homepage) with a non-required string field (subtitle). If updated content gets published with no value in that field, the gatsby develop process breaks, as it starts reporting GraphQL errors:

success createPages — 0.000 s
success createPagesStatefully — 0.062 s
success onPreExtractQueries — 0.008 s
success update schema — 0.264 s
GraphQL Error Unknown field `subtitle` on type `DatoCmsHomepage`

  file: src/pages/index.js

   1 |
   2 |   query PageHomeQuery {
   3 |     homepage: datoCmsHomepage {
   4 |       title
>  5 |       subtitle
     |       ^
   6 |       seoMetaTags {
   7 |         ...GatsbyDatoCmsSeoMetaTags
   8 |       }
   9 |     }
  10 |   }
  11 |

success extract queries from components — 0.158 s

This way, a content editor can break a Gatsby site by just making a field blank (which should be a perfectly valid thing to do).

On DatoCMS's GraphQL playground, the field remains in the schema, just returning a null value, which makes a lot more sense.

I've tried digging into why this happens but not really familiar enough with the Gatsby plugin architecture to tell where the field is being dropped. The closest I got is here, adding if (fieldType === 'string' && itemNode[key] === null) { itemNode[key] = '' } will cause the field to remain in the schema, so no errors, but obviously it's not a clean solution.

Can't access any custom types

I'm using the following settings with the gatsby-default-starter, and have only added this plugin.

   node -v 
   9.4.0

   npm -v
   5.6.0

   "gatsby": "^1.9.184",
   "gatsby-cli": "^1.1.28",
   "gatsby-source-datocms": "1.0.24",

However, I'm only getting the standard types, with no custom types at all. I have added the plugin to gatsby-config with the correct api token. It works without problems for my coworkers and to deploy to Netlify. For some reason it's not working locally for me.

Object.entries and Object.assign are not compatible on IE11

Hi - I was testing a site on IE11 and got the following error popup:

ie11

Looks like Object.entries and Object.assign are not available on IE11, and you're using these methods on these lines:

Object.assign(

Object.entries(item.attributes || {})

I'm far from a pro, but I think you should consider including Object assign and Object entries polyfills for babel, or even the more generic polyfill into your .babelrc json file.

Invariant Violation: GraphQLParser

I can access the data with GraphiQL, but when i use your template:

import React from 'react'

const About = ({ data }) => (
  <article>
    <h1>{data.datoCmsAbout.title}</h1>
    <p>{data.datoCmsAbout.text}</p>
  </article>
)

export default About;

export const query = graphql`
  query AboutQuery {
    datoCmsAbout {
      title
      text
    }
  }
`

It throws this error,

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Invariant Violation: GraphQLParser: Unknown field `rel` on type `attributes_4`. Source: document `GatsbyDatoCmsFaviconMetaTags` file: `GraphQL request`.

Perhaps similar to issue #1 ?

TypeError: Cannot read property 'type' of undefined

Looks like a duplicate of a closed issue that never really had an actual solution posted.

$ gatsby develop
success open and validate gatsby-configs — 0.007 s
success load plugins — 0.186 s
success onPreInit — 1.020 s
success initialize cache — 0.028 s
success copy gatsby files — 0.073 s
success onPreBootstrap — 0.009 s
error Plugin gatsby-source-datocms returned an error


  TypeError: Cannot read property 'type' of undefined
  
  - makeType.js:9 module.exports
    [wfa-new-gatsby]/[gatsby-source-datocms]/makeType.js:9:14
  
  - makeId.js:8 makeId
    [wfa-new-gatsby]/[gatsby-source-datocms]/makeId.js:8:12
  
  - createItemNodes.js:29 itemNodeId
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:29:10
  
  - createItemNodes.js:76 
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:76:24
  
  - Array.map
  
  - createItemNodes.js:75 
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:75:57
  
  - Array.forEach
  
  - createItemNodes.js:49 
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:49:28
  
  - Array.forEach
  
  - createItemNodes.js:43 
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:43:11
  
  - Array.forEach
  
  - createItemNodes.js:40 createItemNodes
    [wfa-new-gatsby]/[gatsby-source-datocms]/createItemNodes.js:40:26
  
  - gatsby-node.js:77 _callee$
    [wfa-new-gatsby]/[gatsby-source-datocms]/gatsby-node.js:77:25
  

success source and transform nodes — 4.535 s
success building schema — 0.331 s
success createPages — 0.000 s
success createPagesStatefully — 0.047 s
success onPreExtractQueries — 0.003 s
success update schema — 0.181 s
warning There are conflicting field types in your data. GraphQL schema will omit those fields.
DatoCmsField.defaultValue:
 - type: boolean
   value: true
 - type: object
   value: { latitude: 47.18227, longitude: -122.29680100000002 }
success extract queries from components — 0.092 s
success run graphql queries — 0.085 s — 8/8 95.97 queries/second
success write out page data — 0.003 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.118 s

package.json

"dependencies": {
    "gatsby": "^2.1.37",
    "gatsby-image": "^2.0.33",
    "gatsby-plugin-manifest": "^2.0.24",
    "gatsby-plugin-offline": "^2.0.25",
    "gatsby-plugin-react-helmet": "^3.0.9",
    "gatsby-plugin-sharp": "^2.0.28",
    "gatsby-source-datocms": "^2.0.2",
    "gatsby-source-filesystem": "^2.0.24",
    "gatsby-transformer-sharp": "^2.1.17",
    "prop-types": "^15.7.2",
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-helmet": "^5.2.0"
  }

I have tried removing .cache many times and not having any luck with that. I have many models in my app, maybe 30 or so, so it is really hard to tell where it is failing. I scoured my schema to make sure that each model had at least one record with every field used at least once. Is there any way to make the errors more useful?

@thetre97

Special (Unescaped) characters in image urls break build

Hello,

Special characters in dato-cms image file names break plugin on build 😢

It's kind of tricky, because I believe asking my users - please avoid spaces and special characters in file names you upload to DatoCms or the site will break - would not work for very long 😄

Not just my machine - CI build fails too. What's interesting - development mode works fine.

// versions: latest
gatsby: 2.0.118
gatsby-source-datocms: 2.0.1
node 11.8.0
Errors:
  Request path contains unescaped characters
  
  GraphQL request (23:7)
  22:       id
  23:       fluid(maxWidth: 2000, maxHeight: 1600, imgixParams: {fm: "jpg", auto: "compress"}) {
            ^
  24:         ...GatsbyDatoCmsFluid

Reproduction

For example - in your example gatsby portfolio stater, there is an image used in gallery with url:

https://www.datocms-assets.com/604/1481209135-Argö-Poster.jpg

Try quering

export const WORK_TEMPLATE_QUERY = graphql`
  query WorkQuery($slug: String!) {
      gallery {
        fluid(maxWidth: 2000, maxHeight: 1600, imgixParams: { fm: "jpg", auto: "compress" }) {
          ...GatsbyDatoCmsFluid
        }
    }
  }
`

Empty Field Throws Invariant Violation

dependencies": {
    "gatsby": "^1.9.149",
    "gatsby-source-datocms": "1.0.16"
...
}

Hi, DatoCMS team. I really enjoy using your CMS with Gatsby! I've run into a problem where an empty field (in my case, a multiple links field called "related") within the DatoCMS admin area will throw an error in Gatsby:

Invariant Violation: Encountered an error trying to infer a GraphQL type for: "related___NODE".   There is no corresponding node with the id field matching: "null"

I'd love to be able to leave this multiple links field blank, as I'm using it to link related articles that I write, and there isn't always a related article to which I should link.

I did some searching around and found an error with the gatsby-source-contentful plugin that seems to be pretty similar.

Gatsby next/v2 support

At the moment, this plugin fails with Gatsby v2.
Could I ask when support for v2 will be added?


(New blank project)

error UNHANDLED EXCEPTION


  ReferenceError: regeneratorRuntime is not defined

  - gatsby-node.js:20
    [sierra]/[gatsby-source-datocms]/gatsby-node.js:20:47

  - gatsby-node.js:134 Object.<anonymous>
    [sierra]/[gatsby-source-datocms]/gatsby-node.js:134:2

  - v8-compile-cache.js:178 Module._compile
    [sierra]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - loader.js:713 Object.Module._extensions..js
    internal/modules/cjs/loader.js:713:10

  - loader.js:612 Module.load
    internal/modules/cjs/loader.js:612:32

  - loader.js:551 tryModuleLoad
    internal/modules/cjs/loader.js:551:12

  - loader.js:543 Function.Module._load
    internal/modules/cjs/loader.js:543:3

  - loader.js:650 Module.require
    internal/modules/cjs/loader.js:650:17

  - v8-compile-cache.js:159 require
    [sierra]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - api-runner-node.js:81 runAPI
    [sierra]/[gatsby]/dist/utils/api-runner-node.js:81:22

  - api-runner-node.js:173 mapSeries
    [sierra]/[gatsby]/dist/utils/api-runner-node.js:173:25

  - map.js:27
    [sierra]/[gatsby]/[async]/internal/map.js:27:9

  - eachOfLimit.js:66 replenish
    [sierra]/[gatsby]/[async]/internal/eachOfLimit.js:66:17

  - eachOfLimit.js:50 iterateeCallback
    [sierra]/[gatsby]/[async]/internal/eachOfLimit.js:50:17

  - onlyOnce.js:12
    [sierra]/[gatsby]/[async]/internal/onlyOnce.js:12:16

  - map.js:29
    [sierra]/[gatsby]/[async]/internal/map.js:29:13

Error: DatoCmsSeoField.image cannot convert to OutputType the following string: 'DatoCmsAsset'

Hi,

I'm unable to start any gatsby project with the datocms plugin added. Upon running the command "gatsby develop", I run into the following issue:

success open and validate gatsby-configs — 0.005 s
success load plugins — 0.389 s
success onPreInit — 0.004 s
success initialize cache — 0.017 s
success copy gatsby files — 0.066 s
success onPreBootstrap — 0.005 s
success loading DatoCMS content — 1.858 s
success source and transform nodes — 1.969 s
error UNHANDLED REJECTION


  Error: DatoCmsSeoField.image cannot convert to OutputType the following string: 'DatoCmsAsset'
  
  - TypeMapper.js:263 TypeMapper.convertOutputFieldConfig
    [tripptee-gatsby]/[graphql-compose]/lib/TypeMapper.js:263:17
  
  - configAsThunk.js:18 resolveOutputConfigAsThunk
    [tripptee-gatsby]/[graphql-compose]/lib/utils/configAsThunk.js:18:41
  
  - configAsThunk.js:36 Object.keys.forEach.name
    [tripptee-gatsby]/[graphql-compose]/lib/utils/configAsThunk.js:36:22
  
  - Array.forEach
  
  - configAsThunk.js:35 resolveOutputConfigMapAsThunk
    [tripptee-gatsby]/[graphql-compose]/lib/utils/configAsThunk.js:35:27
  
  - ObjectTypeComposer.js:144 GraphQLObjectType.gqType._fields
    [tripptee-gatsby]/[graphql-compose]/lib/ObjectTypeComposer.js:144:114
  
  - Array.reduce
  
  - SchemaComposer.js:122 SchemaComposer.buildSchema
    [tripptee-gatsby]/[graphql-compose]/lib/SchemaComposer.js:122:12
  
  - schema.js:480 
    [tripptee-gatsby]/[gatsby]/dist/schema/schema.js:480:47
  
  - Generator.next

Is there anything I could try to sort this? I've tried using a couple of different versions of Gatsby, including the latest one, and I've tried making a fresh datocms project.

Auto-generated URL paths for SEO meta tags and navigation

It's super neat that DatoCMS auto-generates the various _seoMetaTags, thank you 🙂 This currently seems to exclude og:url, but it would be very helpful to have this auto-generated too as it's quite a hassle to rebuild this as a Gatsby node field calculated based on a slug property added to the different models (i.e. custom logic in Gatsby-node, etc).

Would it be possible for DatoCMS to auto-generate a unique localized path for the different resources? This should have the flexibility e.g. that resources in the default language don't have a prefix while others are prepended with a language prefix (e.g /fr, /es, ...).

This path would then be readily available to populate SEO meta tags, to create <link rel="alernate"> to other language versions of the same page, and to build the various navigation links within our websites.

Querying description field results in error

This is my GraphQL query in the layout file:

export const query = graphql`
  query IndexQuery {
   datoCmsSite {
     globalSeo {
       siteName
       twitterAccount,
       description
     }
     faviconMetaTags {
       ...GatsbyDatoCmsFaviconMetaTags
     }    
   }
 }
`;

And this is the error I get in the console

GraphQL Error There was an error while compiling your site's GraphQL queries.
  Invariant Violation: GraphQLParser: Unknown field `description` on type `globalSeo_2`. Source: document `IndexQuery` file: `GraphQL request`.

Fluid images: base64 always undefined

I noticed using gatsby-image with fluid images provided by this plugin does not work correctly right now.

This seems to be due to gatsby-source-datocms returning undefined as base64 for all images when querying for their fluid data.
This seems to have broken recently?

PreviewMode false returning error

Hi

Im getting an error when I use previewMode: false or remove 'previewMode'.
previewMode: true works fine but will return all models in draft too.

In DatoCMS I only have 1 model with draft/published system enabled. Do all models need to have draft/published system for this to work?

TypeError: Cannot read property 'type' of undefined

  - makeType.js:9 module.exports
    [kontrapunkt.com]/[gatsby-source-datocms]/makeType.js:9:14
  
  - makeId.js:8 makeId
    [kontrapunkt.com]/[gatsby-source-datocms]/makeId.js:8:12
  
  - createItemNodes.js:29 itemNodeId
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:29:10
  
  - createItemNodes.js:76 
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:76:24
  
  - Array.map
  
  - createItemNodes.js:75 
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:75:57
  
  - Array.forEach
  
  - createItemNodes.js:49 
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:49:28
  
  - Array.forEach
  
  - createItemNodes.js:43 
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:43:11
  
  - Array.forEach
  
  - createItemNodes.js:40 createItemNodes
    [kontrapunkt.com]/[gatsby-source-datocms]/createItemNodes.js:40:26
  
  - gatsby-node.js:77 _callee$
    [kontrapunkt.com]/[gatsby-source-datocms]/gatsby-node.js:77:25
  
  - gatsby-node.js:3 step
    [kontrapunkt.com]/[gatsby-source-datocms]/gatsby-node.js:3:191
  
  - gatsby-node.js:3 
    [kontrapunkt.com]/[gatsby-source-datocms]/gatsby-node.js:3:361
  
  - next_tick.js:131 _combinedTickCallback
    internal/process/next_tick.js:131:7

HelmetDatoCms should pass props and children to Helmet

Hi, congratulations for the great work @stefanoverna, Dato is a pleasure to use with Gatsby.
However, I notice that HelmetDatoCms uses react-helmet but doesn't pass props or children to it. Which means one would need to use both HelmetDatoCms and Helmet to have a title and a favicon.

Here is what I suggest, copy pasting your code from index.js:

const React = require('react');
const Helmet = require('react-helmet').default;

const HelmetDatoCms = ({ seo, favicon, children, ...rest }) => {
  return React.createElement(
    Helmet,
    rest, // passing remaining props to Helmet
    (seo ? seo.tags : [])
      .concat(favicon ? favicon.tags : [])
      .map((item, i) =>
        React.createElement(
          item.tagName,
          Object.assign(
            { key: i },
            Object.entries(item.attributes || {})
              .reduce((acc, [name, value]) => {
                if (value) {
                  acc[name] = value;
                }
                return acc;
              }, {})
          ),
          item.content
        )
    ).concat(children) // concatenating children of HelmetDatoCms
  );
}

module.exports = { HelmetDatoCms };

Let me know if this would work for you.

Responsive images not working as expected (maybe?)

Hi

I have v1.1.8 installed in our project and I'm trying to understand the responsive image. So, I copied the example provided in the documentation:

      sizes(maxWidth: 600, imgixParams: { fm: "jpg", auto: "compress" }) {
        ...GatsbyDatoCmsSizes
      }

This actually matches my requirement, I would like to fetch an image with a maxSize of 600. And the smaller the device, the smaller the image becomes. It should never fetch an image bigger than 600 because I know for sure I don't need a bigger one.

Unfortunately this is what gets generated:
<img alt="" srcset="https://www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=100&amp;w=150 150w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=200&amp;w=300 300w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=400&amp;w=600 600w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=600&amp;w=900 900w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=800&amp;w=1200 1200w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=1200&amp;w=1800 1800w, https: //www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;h=2300&amp;w=3450 3450w" src="https://www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&amp;fm=jpg&amp;w=600" sizes="(max-width: 600px) 100vw, 600px" style="position: absolute; top: 0px; left: 0px; transition: opacity 0.5s ease 0s; width: 100%; height: 100%; object-fit: cover; object-position: center center; opacity: 1;">

On my screen the browsers happily download https://www.datocms-assets.com/5532/1527088296-photo-1490481920145-fc78891bbb99.jpeg?auto=compress&fm=jpg&h=800&w=1200

Which is way too big. And quite honestly I don't get why it even generates 1200,1800 and even 3450 versions in the srcset even tough I have a maxWidth of 600 set.

Thanks for the help!

Cheers,
Christoph

Gatsby data empty after datocms installation

Issue

When doing gatsby develop, it prints the following error in the console

GraphQL Error Unknown field `content` on type `[tags_2]`

  file: C:/Users/<USER>/Documents/gatsby/project/.cache/fragments/datocms-seo-fragments.js

   1 |
   2 |   fragment GatsbyDatoCmsSeoMetaTags on DatoCmsSeoMetaTags {
   3 |     tags {
   4 |       tagName
>  5 |       content
     |       ^
   6 |       attributes {
   7 |         property
   8 |         content
   9 |         name
  10 |       }
  11 |     }
  12 |   }
  13 |

After which, the project gets compiled successfully.
When loading the page though, it gives an error which described that the data object passed through in const Layout = ({ children, data }) => ( is undefined.

TypeError: Cannot read property 'site' of undefined
new Layout
C:/Users/<USER>/Documents/gatsby/version-test/src/layouts/index.js:11
   8 | const Layout = ({ children, data }) => (
   9 |   <div>
  10 |     <Helmet
> 11 |       title={data.site.siteMetadata.title}
  12 |       meta={[
  13 |         { name: 'description', content: 'Sample' },
  14 |         { name: 'keywords', content: 'sample, something' },
View compiled
▶ 49 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.

How to replicate the issue

  1. Create a new project
    gatsby new project
  2. Install gatsby-source-datocms
    npm install --save gatsby-source-datocms
  3. Add gatsby-source-datocms to gatsby-config.js (I changed the apiToken to my own)
module.exports = {
  siteMetadata: {
    title: 'Gatsby Default Starter',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-source-datocms`,
      options: {
        apiToken: "PUT YOUR API TOKEN HERE",
      },
    },
  ],
}

Noteworthy stuff

  • All queries still work in the localhost:8000/___grapql IDE, just the data object passed inside the layout page is undefined.
  • Data is only undefined after adding gatsby-source-datocms to gatsby-config.js
  • gatsby-config.js is in the root folder, not in the src/ folder.

Can not read property of edges undefined

Hi. I think I'm about to loose my mind but I have an odd bug.

I have added several new models to Dato and I am now trying to gernate pages with gatsby-node.js and create page, but I keep getting this error

error UNHANDLED REJECTION


  TypeError: Cannot read property 'edges' of undefined

  - gatsby-node.js:56 graphql.then.result
    /Users/shannonsmith/Documents/websites/mad/gatsby-node.js:56:39

  - next_tick.js:150 process._tickCallback
    internal/process/next_tick.js:150:11

Here is the snippet from my node file

result.data.allDatoCmsAboutPage.edges.map(({ node }) => {
        createPage({
          path: `about/${node.slug}`,
          component: path.resolve(`./src/templates/aboutpages.js`),
          context: {
            slug: node.slug,
          },
        })
      })

(full file here https://github.com/shansmith01/mad/blob/Integrate-dato/gatsby-node.js)
This same snippet is working for other models I am working with but not allDatoCmsAboutPage.

I can see the data in graphqli

{
  "data": {
    "allDatoCmsAboutPage": {
      "edges": [
        {
          "node": {
            "id": "DatoCmsAboutPage-351444-en",
            "heading": "Terms and Conditions"
          }
        },
        {
          "node": {
            "id": "DatoCmsAboutPage-351445-en",
            "heading": "Privacy Policy"
          }
        },
        {
          "node": {
            "id": "DatoCmsAboutPage-351446-en",
            "heading": "Cookie Policy"
          }
        },
        {
          "node": {
            "id": "DatoCmsAboutPage-351447-en",
            "heading": "Contact Us"
          }
        },
        {
          "node": {
            "id": "DatoCmsAboutPage-351448-en",
            "heading": "About Us"
          }
        },
        {
          "node": {
            "id": "DatoCmsAboutPage-351545-en",
            "heading": "Work for Us"
          }
        }
      ]
    }
  }
}

I can manually make a page, but can't us Gatsby CreatePage
I have also dumped my cache, tried creating a new model (that failed).

System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 9.4.0 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 67.0.3396.99
    Firefox: 61.0
    Safari: 11.1.2
  npmPackages:
    gatsby: ^2.0.0-beta.61 => 2.0.0-beta.61
    gatsby-image: next => 2.0.0-beta.7
    gatsby-plugin-react-helmet: next => 3.0.0-beta.4
    gatsby-plugin-sass: ^2.0.0-beta.6 => 2.0.0-beta.6
    gatsby-plugin-sharp: ^2.0.0-beta.7 => 2.0.0-beta.7
    gatsby-plugin-styled-components: ^3.0.0-beta.3 => 3.0.0-beta.3
    gatsby-source-datocms: ^2.0.0-alpha.6 => 2.0.0-alpha.6
    gatsby-transformer-remark: ^2.1.1-beta.5 => 2.1.1-beta.5
    gatsby-transformer-sharp: ^2.1.1-beta.6 => 2.1.1-beta.6
  npmGlobalPackages:
    gatsby-cli: 1.1.58
    gatsby: 1.9.166

Can someone take a look at this. It feels like a Dato issue not a gatsby issue. Thanks

GraphQL should expose original Id

I think it would be cool if gatsby-source-datocms would expose the real id (without prefixes or suffixes). Not saying it should replace the id attribute, but maybe adding a originalId field or something would be useful (at least in my use case where I need to reconcile with datocms-client).

allDatoCms[Page] breaks gatsby develop when saving changes in Dato

I have this in my gatsby-node.js to generate pages from my Page model in Dato, and it works great.

exports.createPages = ({ graphql, boundActionCreators }) => {
  const { createLayout, createPage, createRedirect } = boundActionCreators;

  return new Promise( (resolve, reject) => {
    graphql(
      `
        {
          allDatoCmsPage {
            edges {
              node {
                id
                slug
              }
            }
          }
        }
      `
    )
    .then((result) => {
      if (result.errors) {
        reject(result.errors);
      }

      const pageTemplate = path.resolve(`./src/templates/pageTemplate.jsx`);

      console.log('Log data', result.data);

      _.each(result.data.allDatoCmsPage.edges, ({ node }) => {
        createPage({
          path: node.slug === 'index' ? '/' : `/${node.slug}/`,
          component: slash(pageTemplate),
          context: {
            id: node.id,
          },
        })
      });

      resolve();
    })
  })
}

However, whenever I save any change in Dato (in any model), gatsby develop fails since allDatoCmsPage is null:

info Detected DatoCMS data change!
Log data { allDatoCmsPage: null }
error Cannot read property 'edges' of null


  TypeError: Cannot read property 'edges' of null

  - gatsby-node.js:30 graphql.then
    /gatsby-node.js:30:41

  - util.js:16 tryCatcher
    /[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    /[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    /[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    /[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    /[bluebird]/js/release/promise.js:693:18

  - promise.js:638 Promise._fulfill
    /[bluebird]/js/release/promise.js:638:18

  - promise.js:432 Promise._resolveCallback
    /[bluebird]/js/release/promise.js:432:57

  - promise.js:524 Promise._settlePromiseFromHandler
    /[bluebird]/js/release/promise.js:524:17

  - promise.js:569 Promise._settlePromise
    /[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    /[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    /[bluebird]/js/release/promise.js:693:18

  - promise.js:638 Promise._fulfill
    /[bluebird]/js/release/promise.js:638:18

  - promise.js:582 Promise._settlePromise
    /[bluebird]/js/release/promise.js:582:21

  - promise.js:614 Promise._settlePromise0
    /[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    /[bluebird]/js/release/promise.js:693:18


error UNHANDLED REJECTION

package.json

{
  "dependencies": {
    "gatsby": "^1.9.232",
    "gatsby-source-datocms": "^1.0.26",
  }
}

Am I missing somethings obvious here?

Surface createdAt and publishedAt values

I've noticed that you have surfaced an item's _updatedAt response to updatedAt. I'm wondering how we can also get access to _createdAt and _publishedAt fields?

I figured adding createdAt below this line would work fine:

itemNode.createdAt = item.createdAt;

And that seems to work fine. But the same is not true for publishedAt. I know this is a value that has to be enabled in the API, but even attempting with models that have this feature enabled does not surface the option.

I'm happy to submit a PR, but curious to get your thoughts on the matter and some direction first.

Gatsby Build fails - GraphQL Error - Modular Content Fields

Gatsby fails to build if there isn't a post with at least one of the modular content fields. For instance, if DatoCmsImage isn't used in a post and only DatoCmsText is used gatsby will fail with the following query. See the following build error.

{
  allDatoCmsBlogPost {
    edges {
      node {
        title
        content {
          ... on DatoCmsText {
            text
          }
          ... on DatoCmsImage {
            image {
              url
            }
          }
        }
      }
    }
  }
}

GraphQL Error Fragment cannot be spread here as objects of type "DatoCmsText" can never be of type "DatoCmsImage".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.