Skip to content

Commit

Permalink
refactor: remoteIdFields no more
Browse files Browse the repository at this point in the history
Generate fragements
  • Loading branch information
ynnoj committed Aug 20, 2020
1 parent 759740c commit 0d4dcfe
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gatsby-source-graphcms/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,24 @@ const createSourcingConfig = async (gatsbyApi, { endpoint, token }) => {

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}Id_
}
}
query NODE_${singularRootFieldName(type)} { ${singularRootFieldName(
type
)}(where: $where) }`,
)}(where: $where) {
..._${type}Id_
}
}
fragment _${type}Id_ on ${type} {
__typename
id
}
`,
nodeQueryVariables: ({ id }) => ({ where: { id } }),
}))

Expand Down

0 comments on commit 0d4dcfe

Please sign in to comment.