Requirements To Schema

All your Query methods has to have following arguments:

{
  offset: {type: GraphQLInt}, 
  limit: {type: GraphQLInt},
  // and
  _id: {type: GraphQLString}
  // or
  id: {type: GraphQLInt}
}

Arguments offset and limit will be used for pagination.

In your resolver it could look like the following:

...
let {offset, limit} = args;
return new Promise((resolve, reject) => {
   Ingredients.find(query)
              .skip(offset)
              .limit(limit)
              .exec((err, res) => err ? reject(err) : resolve(res));
});
...

Second requirements is in your Query method. You have to support id or _id argument with type String or Int based on which kind of storage you use.

This argument will be used to query one item, so make sure that you provide this fields in GraphQL Type's fields as well.

Also, if you use findOne instead of find or any other method to return one item, make sure that you wrap it in array, [{item}].


Keep in mind that CMS will only use GraphQL Types which has one Query method and at least one Mutation method.

All types can only have one Query method [find] to query list of items or one item by providing id, and one or many of three Mutation method [create, update, remove].

results matching ""

    No results matching ""