Closed anuveyatsu closed 3 years ago
@steveoni thanks for analysis. I've implemented fix here: https://github.com/datopian/data-explorer-graphql/commit/9f6319ab72b141240c3770b09eb6ef8cf59cccd7
I also did some update in Hasura server so now it works:
https://datopian.github.io/data-explorer-graphql/?path=/story/templates--power-system-right-now
Closing this as FIXED. Note that you need to handle hyphens in Hasura server as well as described in the analysis of this issue.
When a field name has a hyphen, it breaks the app since it is disallowed by GraphQL spec.
Example: https://datopian.github.io/data-explorer-graphql/?path=/story/templates--power-system-right-now
Tasks
Analysis
Resolver enables us to resolve a value of a type or a field in a schema. A simple example can be like this:
For every field to be resolve we create a resolver function (like the one created for
username
above) that takes inparent
(if a type is reference in another type. I will show an example below),args
: (for argument passed in liketransmisonlines({order_by:{}})
,order_by
is an arg),context
: (graphql and app context to be share among all resolvers) andinfo
: (contains resolver properties).Resolver to fix the Graphql spec would be possible if the graphql query is created like this from the server side:
This method above is okay but might involve some changes in the frontend since we are automatically generating graphql query from the schema and input fields using
graphql-query-builder
NOTE if the above type is created manually containing field like
Exchange_DK1-DK2
it will show error on the server side also.Proposed solution
Since this a spec error base on the field name convention, I assume the field is generated from hasura converting postgress table to graphql. if so, we can customize the field name (e.g
Exchange_DK1-DK2
) to something else. This hasura blog shows how to do that: https://hasura.io/blog/customising-alias-graphql-fields-with-hasura/#:~:text=Server-,Side,-Customisation%20with%20Hasura