Skip to content

Commit

Permalink
fix(gatsby): fix schema printing for gatsby-transformer-json (#35098)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Mar 10, 2022
1 parent 726b51f commit 796800f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 2 additions & 8 deletions packages/gatsby/src/schema/print.ts
Expand Up @@ -27,6 +27,7 @@ import {
import { printBlockString } from "graphql/language/blockString"
import { internalExtensionNames } from "./extensions"
import _ from "lodash"
import { builtInScalarTypeNames } from "./types/built-in-types"

export interface ISchemaPrintConfig {
path?: string
Expand Down Expand Up @@ -342,20 +343,13 @@ export const printTypeDefinitions = ({
}

const internalTypes = [
`Boolean`,
...builtInScalarTypeNames,
`Buffer`,
`Date`,
`Float`,
`ID`,
`Int`,
`Internal`,
`InternalInput`,
`JSON`,
`Json`,
`Node`,
`NodeInput`,
`Query`,
`String`,
]
const internalPlugins = [`internal-data-bridge`]

Expand Down
7 changes: 5 additions & 2 deletions packages/gatsby/src/schema/schema.js
Expand Up @@ -23,7 +23,10 @@ const { getDataStore, getNode, getNodesByType } = require(`../datastore`)
const apiRunner = require(`../utils/api-runner-node`)
const report = require(`gatsby-cli/lib/reporter`)
const { addNodeInterfaceFields } = require(`./types/node-interface`)
const { overridableBuiltInTypeNames } = require(`./types/built-in-types`)
const {
overridableBuiltInTypeNames,
builtInScalarTypeNames,
} = require(`./types/built-in-types`)
const { addInferredTypes } = require(`./infer`)
const {
addRemoteFileInterfaceFields,
Expand Down Expand Up @@ -609,7 +612,7 @@ const checkIsAllowedTypeName = name => {
`reserved for internal use. Please rename \`${name}\`.`
)
invariant(
![`Boolean`, `Date`, `Float`, `ID`, `Int`, `JSON`, `String`].includes(name),
!builtInScalarTypeNames.includes(name),
`The GraphQL type \`${name}\` is reserved for internal use by ` +
`built-in scalar types.`
)
Expand Down
10 changes: 10 additions & 0 deletions packages/gatsby/src/schema/types/built-in-types.ts
Expand Up @@ -147,3 +147,13 @@ export const overridableBuiltInTypeNames = new Set([`SiteSiteMetadata`])

export const builtInTypeDefinitions = (): Array<DocumentNode> =>
allSdlTypes.map(type => parse(type))

export const builtInScalarTypeNames = [
`Boolean`,
`Date`,
`Float`,
`ID`,
`Int`,
`JSON`,
`String`,
]

0 comments on commit 796800f

Please sign in to comment.