Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): fix schema printing for gatsby-transformer-json #35098

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/gatsby/src/schema/print.ts
Original file line number Diff line number Diff line change
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`,
Copy link
Contributor Author

@pieh pieh Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR I essentially just dropped Json from the list, but we still have some questionable type names here - in particular Buffer is raising my eyebrow. For now leaving it as I don't quite understand the reason for it + it doesn't seem to cause problems (yet)

`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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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`,
]