How to use the gatsby/graphql.GraphQLInputObjectType 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 sanity-io / gatsby-source-sanity / src / gatsby-node.ts View on Github external
if (!shouldAddFragments) {
    shouldAddFragments = getNodes().some(node =>
      Boolean(node.internal && node.internal.type === 'SanityImageAsset'),
    )
  }

  if (shouldAddFragments) {
    const program = store.getState().program
    await copy(
      path.join(__dirname, '..', 'fragments', 'imageFragments.js'),
      `${program.directory}/.cache/fragments/sanity-image-fragments.js`,
    )
  }
}

const resolveReferencesConfig = new GraphQLInputObjectType({
  name: 'SanityResolveReferencesConfiguration',
  fields: {
    maxDepth: {
      type: new GraphQLNonNull(GraphQLInt),
      description: 'Max depth to resolve references to',
    },
  },
})

export const setFieldsOnGraphQLNodeType = async (
  context: GatsbyContext & GatsbyOnNodeTypeContext,
  pluginConfig: PluginConfig,
) => {
  const {type} = context
  const typeMapKey = getCacheKey(pluginConfig, CACHE_KEYS.TYPE_MAP)
  const typeMap = (stateCache[typeMapKey] || defaultTypeMap) as TypeMap
github datocms / gatsby-source-datocms / src / hooks / setFieldsOnGraphQLNodeType / nodes / upload / ImgixParamsType.js View on Github external
path: GraphQLString,
  string: GraphQLString,
  timestamp: GraphQLString,
  unit_scalar: GraphQLFloat,
  url: GraphQLString,
};

objectEntries(imgixParams.parameters).forEach(([param, doc]) => {
  fields[camelize(param)] = {
    type:
      doc.expects.length === 1 ? mappings[doc.expects[0].type] : GraphQLString,
    description: `${doc.short_description} (${doc.url})`,
  };
});

module.exports = new GraphQLInputObjectType({
  name: `DatoCmsImgixParams`,
  fields,
});