I'm currently working on Graphql API, and I'm fairly new to this.
I have a function that gets a list of jobs, the GraphQl query response's returned the data normally (non-empty array), but when I execute the function that returns this data via postman or Appolo, I got null in the response.
Here are the query and the response:
query{
filterJobs(input:{}){
reward{
value
}
}
}
------ response in postman: -------
{
"data": {
"filterJobs": null
}
}
------ data returned from the function ----
[ {
id: 'po876elyhftbo2hy5gone',
createdAt: '2022-04-22T14:48:23.568162+00:00',
reward: 60,
orders: [ [Object] ]
}
]
the executed function
module.exports = async function filter(args) {
const response = await callContentAPI({
variables: {
input:args.input,
},
query: `
query filterJobs{
jobs
{
id
createdAt
reward
order{
deadline
deliveryAddress{
city
country
}
}
}
}
}
`,
});
var jobs = response.data.jobs;
if (!printJobs) {
throw new Error("Unable to get orders");
}
return jobs
Can anyone tell me where is the problem? Thanks