I am writing a GraphQL server in Node.js and Express. I have a JSON file of data and so I am using Axios to query data from that JSON file and pass it to GraphQL query,
const RootQuery = new GraphQLObjectType({
name:'RootQueryType',
fields: {
holiday: {
type: Holiday,
args:{
date:{type:GraphQLString},
},
resolve(parentValue, args) {
return axios.get('http://localhost:3000/holidays?date='+ args.date).then(res => res.data);
}
},
On console.log(res.data)
, I am getting the data, however, on querying by date from GraphiQL, I am getting
{
"data": {
"holiday": {
"holiday": null
}
}
}