hasura / hasura/graphql-engine
Brainstorming/feedback on approach for custom schema resolvers
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
Not having much experience with Haskell, I'm curious about a potential approach to adding custom types/operations/resolvers to the generated schema by using an RPC framework. This would be an alternative to custom actions.
Basically, add a command-line argument to specify the address to a custom server (e.g. gPRC, MessagePack, etc). Then, say in the console, add a custom type + query operation & mark it being routed to the RPC server. For example, if using gRPC, a server implementation is generated from the Hasura-bundled protoc IDL. The server can have a startup method, a process method, & a shutdown method. Process can get the operation name, input args, etc. & return the response. It can potentially offer better streaming support too. It can also potentially be faster too due to the binary wire protocol and potential for a keep-alive/http2 transport.
gPRC certainly has its warts, and I was just using it as an example here, but I can definitely see something like that being used. One reason I was looking at this is because I switched to using httpOnly cookies as the primary mechanism for token storage (for security reasons), but Hasura does not currently support it, so I had to add a fallback to the Authorization header. The alternative was to configure an auth webhook that would process the cookie and return it to Hasura, but that adds a fair amount of pre-processing weight to a request. If it needs to be done in a per-request basis, then using a binary wire protocol over http2 or plain tcp sockets would save a fair chunk of time on that. However, offering an RPC option for custom extensions has broader uses beyond that.
I'm not experienced with Haskell beyond the basics, so I wouldn't be able to implement something like this soon. This is just to gather feedback & see if it's worth looking into. There could very well be major issues that would make it more trouble than it's worth.
Thoughts? Comments? :)
Contributor guide
Research direction
No files, tests, or implementation entry points are identified. Begin by reviewing the existing custom actions approach and the generated schema boundary, then assess whether an RPC server could support custom types, operations, resolvers, lifecycle methods, and streaming; done would be a decided, scoped design rather than an implementation patch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, grpc, haskell
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100