From a7d4b5bac30e02d42c036cbea50d580c28e25b68 Mon Sep 17 00:00:00 2001 From: Jonathan Steele Date: Tue, 25 Aug 2020 09:48:40 +0100 Subject: [PATCH] refactor: remoteIdFields no more (#104) * chore(deps): Bump gatsby-graphql-source-toolkit * refactor: remoteIdFields no more Generate fragements * fix: Ensure MarkdownNode type always created * chore(deps): Bump gatsby-graphql-source-toolkit --- gatsby-source-graphcms/gatsby-node.js | 19 ++++++++++++++++--- gatsby-source-graphcms/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gatsby-source-graphcms/gatsby-node.js b/gatsby-source-graphcms/gatsby-node.js index 7bc1e29..21c0ff0 100644 --- a/gatsby-source-graphcms/gatsby-node.js +++ b/gatsby-source-graphcms/gatsby-node.js @@ -54,14 +54,24 @@ const createSourcingConfig = async ( const gatsbyNodeTypes = possibleTypes.map((type) => ({ remoteTypeName: type.name, - remoteIdFields: ['__typename', 'id'], queries: ` query LIST_${pluralRootFieldName(type)} { ${pluralRootFieldName( type - )}(first: $limit, skip: $offset) } + )}(first: $limit, skip: $offset) { + ..._${type.name}Id_ + } + } query NODE_${singularRootFieldName(type)} { ${singularRootFieldName( type - )}(where: $where) }`, + )}(where: $where) { + ..._${type.name}Id_ + } + } + fragment _${type.name}Id_ on ${type.name} { + __typename + id + } + `, nodeQueryVariables: ({ id }) => ({ where: { id } }), })) @@ -198,6 +208,9 @@ exports.createSchemaCustomization = ( if (buildMarkdownNodes) createTypes(` + type GraphCMS_MarkdownNode implements Node { + id: ID! + } type GraphCMS_RichText { markdownNode: GraphCMS_MarkdownNode @link } diff --git a/gatsby-source-graphcms/package.json b/gatsby-source-graphcms/package.json index 2f7785d..195efa1 100644 --- a/gatsby-source-graphcms/package.json +++ b/gatsby-source-graphcms/package.json @@ -13,7 +13,7 @@ ], "license": "MIT", "dependencies": { - "gatsby-graphql-source-toolkit": "0.2.2", + "gatsby-graphql-source-toolkit": "0.4.1", "gatsby-source-filesystem": "2.3.18", "he": "1.2.0", "node-fetch": "2.6.0" diff --git a/yarn.lock b/yarn.lock index 81568bb..c0febff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6123,10 +6123,10 @@ gatsby-graphiql-explorer@^0.4.10: dependencies: "@babel/runtime" "^7.10.3" -gatsby-graphql-source-toolkit@0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/gatsby-graphql-source-toolkit/-/gatsby-graphql-source-toolkit-0.2.2.tgz#07c37eb23c330099c9e9d3d59b3981a999a1ab2f" - integrity sha512-gx98EGdzpq3LDd5YNTSdciZDExhOQRLW2kzrc9tLf61N2oV3pnQ1zIrQ5RJHNjKwLUndyfDRmK85bYqYLLcPuA== +gatsby-graphql-source-toolkit@0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/gatsby-graphql-source-toolkit/-/gatsby-graphql-source-toolkit-0.4.1.tgz#09018b007038867d1095821530e831395b1593a7" + integrity sha512-FvdFD0Qh+K6sMTpVHX+Imd6iFk7jsIEIxieEm82gFa9suI5osUKtUZPPvtkqbjyYKYWuPObWv/XvKJDc9JxyuA== dependencies: "@types/node-fetch" "^2.5.7" lodash "^4.17.15"