GraphQL: overriding a resolver?

124
March 24, 2018, at 9:12 PM

The example may seem stupid but it clearly illustrates the problem I'm facing.

Suppose, there's a Zoo, Animal and a List type:

type Zoo {
  ...
  customAnimalsNames: [String] 
  animals: [Animal]
  city: String!
}
type List {
  ...
  zoo: [Zoo]
  ...
}
type Animal {
  ...
  name: String!
}

I have an Animals collection where I store data about each animal. Suppose, each user can have a list of zoos. A user also can give custom names to the animals.

If my initial resolver for a field animals would be something like this:

import Animals from './collection';
export default (root, context, {userId}) => {
  ...
  return Animals.find({}).fetch();
}

How can I modify it so that animals field would return a list of animals with custom names.

How can I modify my List query:

list(_id: String){
   zoo: {
     animals
   }
}

And get animals with custom names?

READ ALSO
Can I bypass cloudflare?

Can I bypass cloudflare?

Can I bypass cloudflare or use another method from this page My code:

159
Is form.parse() called at the same time as form.on(“end”) if used in the same script?

Is form.parse() called at the same time as form.on(“end”) if used in the same script?

It is not very clear from the description of both parse and on(end) what the actual order of processing is

52
Node.js , Express ejs views error

Node.js , Express ejs views error

EJS Error: Failed to lookup view "admin_landing2" in views directory "/Users/aryanarora/Desktop/asn3/views"while trying make a call to localhost/8080/yolo I am getting the same error even if I switch to hbs

134
NodeJS routing goes to '/' for defined page

NodeJS routing goes to '/' for defined page

I have defined routes in my node app as;

68