How to use the gatsby/graphql.GraphQLObjectType 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 ChristopherBiscardi / gatsby-mdx / packages / gatsby-mdx / gatsby / extend-node-type.js View on Github external
// convert the mdxast to back to mdast
      remove(mdast, "import");
      remove(mdast, "export");
      visit(mdast, "jsx", node => {
        node.type = "html";
      });

      const textAst = await remark()
        .use(stripMarkdown)
        .run(mdast);

      return remark().stringify(textAst);
    }

    const HeadingType = new GraphQLObjectType({
      name: `MdxHeadingMdx`,
      fields: {
        value: {
          type: GraphQLString,
          resolve(heading) {
            return heading.value;
          }
        },
        depth: {
          type: GraphQLInt,
          resolve(heading) {
            return heading.depth;
          }
        }
      }
    });
github medialab / website / site / schema.js View on Github external
name: model + '__' + k + '__relation',
          fields: {
            ...otherSchema,
            id: {
              type: GraphQLTypes.GraphQLString
            }
          }
        });

        current[model][k] = {type: new GraphQLTypes.GraphQLList(RelationType)};
      }
    }
  }

  // Handling cover
  const ProcessedType = new GraphQLTypes.GraphQLObjectType({
    name: model + '__processed_image_string',
    fields: {
      small: {
        type: GraphQLTypes.GraphQLString
      },
      medium: {
        type: GraphQLTypes.GraphQLString
      },
      large: {
        type: GraphQLTypes.GraphQLString
      }
    }
  });

  const CoverType = new GraphQLTypes.GraphQLObjectType({
    name: model + '__cover',
github angeloashmore / gatsby-source-prismic / src / customTypeJsonToGraphQLSchema.js View on Github external
// mocked node. This is required to ensure Gatsby processes the field as a Date
// to provide date arguments like `formatString`.
const GraphQLDate = new GraphQLScalarType({
  name: 'Date',
  serialize: R.identity,
})

// Provides the ability to control the return value of ImageURL fields on the
// mocked node. This is required to allow setting the image URL when creating
// mock localFile fields.
const GraphQLImageURL = new GraphQLScalarType({
  name: 'ImageURL',
  serialize: R.identity,
})

const GraphQLPrismicHTML = new GraphQLObjectType({
  name: generateNamespacedTypeName('HTML'),
  fields: {
    html: { type: new GraphQLNonNull(GraphQLString) },
    text: { type: new GraphQLNonNull(GraphQLString) },
  },
})

const GraphQLPrismicGeoPoint = new GraphQLObjectType({
  name: generateNamespacedTypeName('GeoPoint'),
  fields: {
    latitude: { type: new GraphQLNonNull(GraphQLFloat) },
    longitude: { type: new GraphQLNonNull(GraphQLFloat) },
  },
})

const GraphQLPrismicEmbed = new GraphQLObjectType({
github angeloashmore / gatsby-source-prismic / src / customTypeJsonToGraphQLSchema.js View on Github external
// mocked node. This is required to allow setting the image URL when creating
// mock localFile fields.
const GraphQLImageURL = new GraphQLScalarType({
  name: 'ImageURL',
  serialize: R.identity,
})

const GraphQLPrismicHTML = new GraphQLObjectType({
  name: generateNamespacedTypeName('HTML'),
  fields: {
    html: { type: new GraphQLNonNull(GraphQLString) },
    text: { type: new GraphQLNonNull(GraphQLString) },
  },
})

const GraphQLPrismicGeoPoint = new GraphQLObjectType({
  name: generateNamespacedTypeName('GeoPoint'),
  fields: {
    latitude: { type: new GraphQLNonNull(GraphQLFloat) },
    longitude: { type: new GraphQLNonNull(GraphQLFloat) },
  },
})

const GraphQLPrismicEmbed = new GraphQLObjectType({
  name: generateNamespacedTypeName('Embed'),
  fields: {
    author_name: { type: new GraphQLNonNull(GraphQLString) },
    author_url: { type: new GraphQLNonNull(GraphQLString) },
    cache_age: { type: new GraphQLNonNull(GraphQLString) },
    embed_url: { type: new GraphQLNonNull(GraphQLString) },
    html: { type: new GraphQLNonNull(GraphQLString) },
    name: { type: new GraphQLNonNull(GraphQLString) },
github angeloashmore / gatsby-source-prismic / src / customTypeJsonToGraphQLSchema.js View on Github external
sliceFields.primary = {
          type: new GraphQLObjectType({
            name: generateNamespacedTypeName(
              customTypeId,
              sliceZoneId,
              fieldId,
              'Primary',
            ),
            fields: R.map(fieldToGraphQLType(customTypeId), primaryFields),
          }),
        }

      if (!R.isEmpty(itemsFields))
        sliceFields.items = {
          type: new GraphQLList(
            new GraphQLObjectType({
              name: generateNamespacedTypeName(
                customTypeId,
                sliceZoneId,
                fieldId,
                'Item',
              ),
              fields: R.map(fieldToGraphQLType(customTypeId), itemsFields),
            }),
          ),
        }

      // GraphQL type must match source plugin type.
      const sliceType = new GraphQLObjectType({
        name: generatePublicTypeName(customTypeId, sliceZoneId, fieldId),
        fields: sliceFields,
      })
github jessestuart / gatsby-source-s3-image / src / set-fields-on-graphql-node-type.ts View on Github external
export default ({ type }: ExtendNodeTypeOptions) => {
  if (type.name !== 'S3ImageAsset') {
    return Promise.resolve()
  }

  return Promise.resolve({
    ETag: { type: GraphQLString },
    EXIF: {
      resolve: (image: S3ImageAssetNode) => ({
        ...type,
        ...resolveExifData(image),
      }),
      type: new GraphQLObjectType({
        fields: {
          DateCreatedISO: { type: GraphQLString },
          DateTimeOriginal: { type: GraphQLInt },
          Exposure: { type: GraphQLString },
          ExposureTime: { type: GraphQLFloat },
          FNumber: { type: GraphQLFloat },
          FocalLength: { type: GraphQLFloat },
          ISO: { type: GraphQLInt },
          LensModel: { type: GraphQLString },
          Model: { type: GraphQLString },
          ShutterSpeedFraction: { type: GraphQLString },
          ShutterSpeedValue: { type: GraphQLFloat },
        },
        name: 'ExifData',
      }),
    },
github medialab / website / site / schema.js View on Github external
exports.graphQLSchemaAdditionForSettings = function(schemas, getNode) {

  const relationTypes = {};

  for (const k in schemas) {
    relationTypes[k] = new GraphQLTypes.GraphQLObjectType({
      name: _.capitalize(k),
      fields: {
        ...schemas[k],
        id: {
          type: GraphQLTypes.GraphQLString
        }
      }
    });
  }

  const ItemType = new GraphQLTypes.GraphQLObjectType({
    name: 'settings__item',
    fields: {
      id: {
        type: GraphQLTypes.GraphQLString
      },
github medialab / website / site / schema.js View on Github external
const ProcessedType = new GraphQLTypes.GraphQLObjectType({
    name: model + '__processed_image_string',
    fields: {
      small: {
        type: GraphQLTypes.GraphQLString
      },
      medium: {
        type: GraphQLTypes.GraphQLString
      },
      large: {
        type: GraphQLTypes.GraphQLString
      }
    }
  });

  const CoverType = new GraphQLTypes.GraphQLObjectType({
    name: model + '__cover',
    fields: {
      url: {
        type: GraphQLTypes.GraphQLString
      },
      processed: {
        type: ProcessedType
      }
    }
  });

  if ('coverImage' in current[model])
    return;

  current[model].coverImage = {
    type: CoverType,
github medialab / website / site / schema.js View on Github external
const GraphQLTypes = require('gatsby/graphql');
const sharp = require('sharp');
const path = require('path');
const _ = require('lodash');

const GraphQLTranslatedString = new GraphQLTypes.GraphQLObjectType({
  name: 'TranslatedString',
  fields: {
    en: {
      type: GraphQLTypes.GraphQLString
    },
    fr: {
      type: GraphQLTypes.GraphQLString
    }
  }
});

exports.graphQLSchemaAdditionForSettings = function(schemas, getNode) {

  const relationTypes = {};

  for (const k in schemas) {
github Takumon / blog / plugins / gatsby-remark-headings-detail / gatsby-node.js View on Github external
type: GraphQLString,
        resolve: ({value}) => value,
      },
      id: {
        type: GraphQLString,
        resolve: ({id}) => id,
      },
      depth: {
        type: GraphQLInt,
        resolve: ({depth}) => depth,
      },
    }
  })


  const HeadingType = new GraphQLObjectType({
    name: `MarkdownHeadingDetail`,
    fields: {
      value: {
        type: GraphQLString,
        resolve: ({value}) => value,
      },
      id: {
        type: GraphQLString,
        resolve: ({id}) => id,
      },
      depth: {
        type: GraphQLInt,
        resolve: ({depth}) => depth,
      },
      parents: {
        type: new GraphQLList(ParentHeadingType),