Support schema extension for GraphQL and REST data sources
See original GitHub issueContext
Consider the following. We’re storing image metadata in our Postgres database using the PostGIS extension. Hasura supports PostGIS natively and creates a custom GraphQL scalar called geography
to store the GPS coordinates. The value of this type is a GeoJSON. See https://hasura.io/docs/latest/schema/postgres/postgresql-types/#geography
We use Hasura as a backend for WunderGraph. Using the schema generated by WunderGraph, suppose I now try to query an image, e.g.
query GetImages {
hasura_images {
id
location
}
}
where location
has geography
type. Then WunderGraph would complain that returning location
field in the response has incorrect type:
ERROR ResolveGraphQLResponse for query failed {"component": "@wundergraph/node", "error": "invalid value type 'object' for path /data/hasura_images/1/location, expecting string, got: {\"type\":\"Point\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"urn:ogc:def:crs:EPSG::4326\"}},\"coordinates\":[-0.136667,50.818889]}. You can fix this by configuring this field as Int/Float Scalar"}
This kinda makes sense as Hasura returns a GeoJSON object for location
but WunderGraph can’t know that from introspection alone. The generated wundergraph.api.schema.graphql
simply has:
scalar hasura_geography
So it seems we want to override the geography
type generated by WunderGraph.
Feature Request
It seems that this is what we want: https://docs.wundergraph.com/docs/guides/extend-json-fields-with-more-specific-types
But currently, it’s only exposed to database sources.
It would be great if we can also extend GraphQL schemas from GraphQL sources (and maybe REST as well).
Issue Analytics
- State:
- Created a year ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
Hi @Slickstef11, sorry had a busy week! I’ve added a ticket to our backlog which I’ll pick up next week to look at this
The PR above contains the changes!