Two main APIs

createTypes and createResolvers.

createTypes allows the introduction or “polishing” of types.

you can use directives to force inference or non-inference of fields.

wrong type returned from resolver

name: `MdxBlogPost`,
fields: {
// no type here! type is required
title: {
resolve(source, args, context, info) {
console.log(source, args, context, info);

shows this error

Error: MdxBlogPost.title provided incorrect OutputType: '{}'
- TypeMapper.js:282 TypeMapper.convertOutputFieldConfig
- configAsThunk.js:18 resolveOutputConfigAsThunk
- configAsThunk.js:36
- Array.forEach
- configAsThunk.js:35 resolveOutputConfigMapAsThunk
- ObjectTypeComposer.js:144 GraphQLObjectType.gqType._fields
- Array.reduce
- SchemaComposer.js:122 SchemaComposer.buildSchema
- schema.js:480
error Command failed with exit code 1.
info Visit for documentation about
this command.

schema out of info, get the type, get the resolver, call it

(as long as it doesn’t rely on GraphQL context)

also create the fieldname


multiple interfaces for BlogPostWithComments, BlogPostWithMultipleAuthors, BlogPostv2, etc, all available so that themes can choose which one they support

define new interface (BlogPostWithComments), old resolvers are already defined, so grab originalResolver off the type and execute.

(kinda) Not Possible to get resolver-specific types

can do this, but it’s a stop-gap and will be more formally supported

const type = info.schema.getType('MarkdownRemark`)
const resolver = type.getFields().html.resolve
const html = resolver(markdownRemarkNode, {}, context, { fieldName: 'html'})

Replaces setFieldsOnGraphQLNodeType() (but the API isn’t deprecated yet).

const { paginate } = require('gatsby/dist/schema/resolvers')
allBlogPost: {
// type should go automatically because blog post is a node
resolve: async (source, args, context, info) => {
const result = context.nodeModel.runQuery(
query: args,
firstOnly: false,
type: info.schema.getType('YourBackingType'),
{ path: context.path, connectionType: typeName }
return paginate(result, { skip: args.skip, limit: args.limit })

import schemacomposer
create interface type as the typecomposer