Closed JonathanWbn closed 7 years ago
This was my solution:
// schema.js
const { GraphQLObjectType, GraphQLSchema } = require('graphql');
const { getModels } = require('@risingstack/graffiti-mongoose/lib/model');
const { getFields } = require('@risingstack/graffiti-mongoose/lib/schema');
const { contactMutation } = require('./mutations');
const { contactQuery } = require('./queries');
const models = require('../models');
const graffitiModels = getModels(models);
const graffitiFields = getFields(graffitiModels);
const rootQuery = graffitiFields.query._typeConfig;
const rootMutation = graffitiFields.mutation._typeConfig;
Object.assign(rootQuery.fields, {
contact: contactQuery.user,
contacts: contactQuery.users,
});
Object.assign(rootMutation.fields, {
createContact: contactMutation.createContact,
});
module.exports = new GraphQLSchema({
query: new GraphQLObjectType(rootQuery),
mutation: new GraphQLObjectType(rootMutation),
});
I hope this can help you :).
Hey there, first of all thanks for the package, really good stuff.
I am trying to figure out how to write custom queries, but I am struggling with the syntax. At the moment I am doing something like this for my schema:
When I run the test query tho i just get this result:
Where am I going wrong here?