I am studying GraphQL
and I get a bit confused from different implementations on the specific issue when writing the fields
of a GraphQLObjectType
.
What is the difference between these two implementations?
1.
var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: { // as object
echo: {
type: GraphQLString,
args: {
email: { type: EmailType }
},
resolve: (root, {email}) => {
return email;
}
}
}
})
});
var ComplicatedArgs = new GraphQLObjectType({
name: 'ComplicatedArgs',
fields: () => ({ // as function
complexArgField: {
type: GraphQLString,
args: {
complexArg: { type: ComplexInput }
},
}
}),
});
echo
field, the second snippet only creates an object type with acomplexArgField
field and no resolver. – Civility