Graphql-engine: Option to allow (ignore) unexpected fields in webhook response

Created on 5 Sep 2020  路  3Comments  路  Source: hasura/graphql-engine

I was amazed to find out that Hasura Actions could be used to integrate existing REST APIs into Hasura schema. Thank you!

Yet, I did run into two issues:

  • Because actions create only POST requests, calling REST endpoints for other methods don't work out of the box: https://github.com/hasura/graphql-engine/issues/4862 (in my use case I was able add support for configuring required method as action request header)

  • Unless all fields in response are defined in response type, queries fail with unexpected fields in webhook response error.

Adding all response fields into custom type even if they are not really required could be a lot of extra work. It might also be impossible until actions response may contain nested types: https://github.com/hasura/graphql-engine/issues/4796

Simply having an option to ignore all action response field not expected in action type would make actions a lot more practical for integrating existing REST APIs with Hasura (unless you have even better ideas for similar use cases).

actions enhancement

Most helpful comment

I'm sorry if I was ambiguous. I don't think I am asking to remove schema-bound constraints, but if it would be possible for Hasura to just ignore any data outside schema when parsing a webhook / action response.

My context here is that I was playing with on idea to use Hasura actions to merge existing REST API with the schema. Not the full responses, but only the parts defined in action schemas. This already works for POST endpoints when all fields in the response are defined. But REST APIs may be very verbose and defining all the fields even when only a few of them are really required is a lot of work. In this use case it would be ok for Hasura to just ignore and drop parts of the response in schema.

I know that actions were not designed for this use case, but as I said, I was surprised how well they already worked for this.

All 3 comments

Hasura being exposed as GraphQL endpoint is a core feature. Removing schema-bound constraints would break a lot of things both on your frontend and in Hasura, for example Action relationships

I'm sorry if I was ambiguous. I don't think I am asking to remove schema-bound constraints, but if it would be possible for Hasura to just ignore any data outside schema when parsing a webhook / action response.

My context here is that I was playing with on idea to use Hasura actions to merge existing REST API with the schema. Not the full responses, but only the parts defined in action schemas. This already works for POST endpoints when all fields in the response are defined. But REST APIs may be very verbose and defining all the fields even when only a few of them are really required is a lot of work. In this use case it would be ok for Hasura to just ignore and drop parts of the response in schema.

I know that actions were not designed for this use case, but as I said, I was surprised how well they already worked for this.

I'm also using actions for querying a REST endpoint and currently I need to extract those specific fields in use on the query from the returning objects, repeating the format of the the Action definition output.

Would be nice to avoid repeating these fields on the request handler.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rikinsk-zz picture rikinsk-zz  路  3Comments

EmrysMyrddin picture EmrysMyrddin  路  3Comments

Fortidude picture Fortidude  路  3Comments

bogdansoare picture bogdansoare  路  3Comments

leoalves picture leoalves  路  3Comments