Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

js generated schema support? #95

Closed
stephen-dahl opened this issue Aug 26, 2018 · 1 comment
Closed

js generated schema support? #95

stephen-dahl opened this issue Aug 26, 2018 · 1 comment

Comments

@stephen-dahl
Copy link

Is it possible to use this with schemas generated using js instead of SDL? for example

const {
	GraphQLObjectType,
	GraphQLListType,
	GraphQLString,
} = require('graphql');

const Recipe = new GraphQLObjectType({
	fields: () => ({
		name: { type: GraphQLString },
		steps: { type: new GraphQLListType(GraphQLString) },
	}),
});

how would you apply annotations in this context?

@johnymontana
Copy link
Member

Hey @stephen-dahl - yes, you just need to create the relevant GraphQLDirective and add it to your GraphQLObjectType object. Once you've created the GraphQLSchema object you can pass that to augmentSchema or makeAugmentedSchema instead of type definitions to create the auto-generated resolvers and other schema augmentations.

There's an example in this issue: graphql/graphql-js#1343 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants