graphjin
graphjin copied to clipboard
Validate Input Data Structure
What would you like to be added:
Validate the input data structure and generate error to ensure that malformed SQL is not generated
Atleast do this in devmode
Why is this needed:
This is needed because it really confusing for the developer to debug the error, its not clear how one can figure out if the got the wrong graphjin grapql (for a given schema) or if there is a bug somewhere in the graphjin implementation. Right now we are basically believing that everything works, but as a compiler, it should spit out better error messages.
Here's and example one of the errors we are getting, I cant share the schema in public (its gonna be a lot of effort to share the entire schema and stuff to replicate. I will be happy to send it over privately if absolutely necessary.
query failed {"op": "Mutation", "name": "UpdateEnquiryAfterOrder", "role": "anon", "responseTimeMs": 366, "sql": "/* action='UpdateEnquiryAfterOrder',controller='graphql',framework='graphjin' */ WITH _sg_input AS (SELECT $1 :: json AS j), enquiries_0 AS (UPDATE \"application\".\"enquiries\" SET () = ( SELECT FROM _sg_input i, json_to_record(i.j) as t()) WHERE ((\"enquiries\".\"id\") = $2) RETURNING \"application\".\"enquiries\".*), enquiries_1 AS (UPDATE \"application\".\"enquiries\" SET (\"status\") = ( SELECT \"t\".\"status\" :: enquiry_status FROM _sg_input i, enquiries_0 _x_enquiries, json_to_record(i.j->'enquiries') as t(\"status\" enquiry_status)) FROM _sg_input i, enquiries_0 _x_enquiries, json_to_record(i.j->'enquiries') as t(\"status\" enquiry_status) WHERE ((\"enquiries\".\"port_of_supply_id\") = (\"_x_ports\".\"id\") AND ) RETURNING \"application\".\"enquiries\".*), \"enquiries\" AS (SELECT * FROM enquiries_0 UNION ALL SELECT * FROM enquiries_1) SELECT jsonb_build_object('enquiries', __sj_0.json) AS __root FROM ((SELECT true)) AS __root_x LEFT OUTER JOIN LATERAL (SELECT COALESCE(jsonb_agg(__sj_0.json), '[]') AS json FROM (SELECT to_jsonb(__sr_0.*) AS json FROM (SELECT \"enquiries_0\".\"id\" AS \"id\", 'enquiries' AS \"__typename\" FROM (SELECT \"enquiries\".\"id\" FROM \"enquiries\" WHERE ((\"enquiries\".\"id\") = $2) LIMIT 2000) AS \"enquiries_0\") AS \"__sr_0\") AS \"__sj_0\") AS \"__sj_0\" ON true", "error": "ERROR: syntax error at or near \")\" (SQLSTATE 42601)"}