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
}
]
}
]
}
2
Answers
According to Graphile custom queries documentation: Custom queries must be marked as STABLE (or IMMUTABLE, though that tends to be less common)
After that my query appears in the GraphiQL explorer as expected!
Thanks to Graphile help forum
get_eligible_shifts
needs to be included as a query in your schema. For example: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.