How to use the gatsby/graphql.printSchema function in gatsby

To help you get started, we’ve selected a few gatsby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angeloashmore / gatsby-source-prismic / src / __tests__ / schema.js View on Github external
test('parse schema from provided JSON', () => {
  const schema = customTypeJsonToGraphQLSchema('page', customTypeJson)
  const printedSchema = printSchema(schema)

  const mockedSchema = easygraphqlMock(printedSchema)

  // console.log(printedSchema)

  // console.log(util.inspect(printedSchema, false, null, true))
})
github damassi / gatsby-starter-typescript-rebass-netlifycms / gatsby-node.js View on Github external
exports.onPostBootstrap = async ({ store }) => {
  try {
    const { schema } = store.getState()
    const jsonSchema = await graphql(schema, introspectionQuery)
    const sdlSchema = printSchema(schema)

    write.sync("schema.json", JSON.stringify(jsonSchema.data), {})
    write.sync("schema.graphql", sdlSchema, {})

    console.log("\n\n[gatsby-plugin-extract-schema] Wrote schema\n") // eslint-disable-line
  } catch (error) {
    console.error(
      "\n\n[gatsby-plugin-extract-schema] Failed to write schema: ",
      error,
      "\n"
    )
  }
}
github angeloashmore / gatsby-source-prismic / src / createTemporaryMockNodes.js View on Github external
const jsonSchemaToMockNode = (type, jsonSchema) => {
  // Convert the JSON schema to a collection of mock objects.
  const schema = customTypeJsonToGraphQLSchema(type, jsonSchema)
  const printedSchema = printSchema(schema)
  const mockedSchema = easygraphqlMock(printedSchema, {
    Date: MOCK_DATE,
    ImageURL: MOCK_IMAGE_URL,
  })

  // mockedSchema contains mocks for every subtype, but we only need the main
  // root mock node.
  const rootMockedNode = mockedSchema[generateTypeName(type)]

  const MockNode = createNodeFactory(type)

  return MockNode(rootMockedNode)
}