I have the following arrangement:
const Person = function(name, age, interest) {
this.name = name;
this.age = age;
this.interest = interest;
}
const people = [
new Person("rajat", 29, ['prog','food','gym']),
new Person("ravi", 23, ['travel', 'cook', 'eat']),
new Person("preeti", 19, ['comedy', 'arts', 'beauty'])
];
const schema = buildSchema(`
type Person {
name: String,
age: Int,
interest: [String]
},
type Query {
hello: String,
giveTen(input: Int!): Int,
person(name: String!): Person!,
}
`);
const root = {
hello: () => 'Hello World',
giveTen: (args) => args.input * 10,
person: (args) => people.filter(item => item.name === args.name),
};
When I run the following query:
query PersonDetails {
person(name: "rajat") {
name
age
interest
}
}
I get bunch of nulls, when there clearly is matching data in people array.
{
"data": {
"person": {
"name": null,
"age": null,
"interest": null
}
}
}