I have a SQL function that I am unable to query with Postgraphile. I am getting Cannot query field "get_eligible_shifts" on type "Query"."
I noticed that in the PostGraphiQL the function does not appear. Why would I not be able to query on my SQL function?
Postgraphile query
{
get_eligible_shifts(
args: {workerId: 1}
) {
id
start
end_time
profession
worker_name
facility_id
facility_name
worker_document_id
facility_requirement_id
}
}
errror
{
"errors": [
{
"message": "Cannot query field "get_eligible_shifts" on type "Query".",
"locations": [
{
"line": 2,
"column": 3
}
]
}
]
}
1 Answer
get_eligible_shifts
needs to be included as a query in your schema. For example:
type Query {
get_eligible_shifts(args: ArgsInputType): [Shifts]
... more query definitions
}
Only once a query has been included in the schema can you resolve it using a resolver, in your case the SQL function you allude to.