Skip to content

Using extend type with GraphQL API #3266

Answered by IvanGoncharov
bombillazo asked this question in Q&A
Discussion options

You must be logged in to vote

With

const myType = new GraphQLObjectType({
  name: 'MyType',
  fields: {
    'prop': { type: GraphQLInt },
  },
});

you can do the following:

const myTypeConfig = myType.toConfig();

const exptendedMyType = new GraphQLObject({
  ...myTypeConfig,
  fields: {
    ...myTypeConfig.fields,
    newProp: { type: GraphQLString },
  },
});

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bombillazo
Comment options

Answer selected by saihaj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants