99designs/gqlgen

Crazy plugin idea

Offen

#3.906 geöffnet am 10.11.2025

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (1.250 Forks)auto 404
help wantedproposal

Repository-Metriken

Stars
 (10.737 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 11T) (20 gemergte PRs in 30 T)

Beschreibung

I want to see what the maintainers think about this idea, I'm okay to pursue on this codebase or others first and merge here as well,

Context: We sometimes want REST applications for hotpath since the complexity of query parsing from gateway, then in the subgraph does add some CPU overhead. I know what we do inside of the resolver matters, but there are times when it does make a difference.

Currently, the only option is to create a REST version of the same thing duplicating everything.

Since we have resolver that has the dependency anyway, and we have the AST, what I was thinking is generating the REST automatically using a plugin, and one could enable the plugin and decorate using a specific directive to mark the query/mutation as included in the REST version.

Now the way it'd work is by short circuiting the graphql parsing bit, so it'd be basically:

  • REST request matches one of the many handler
  • handler gets called,
  • handler has body that simply calls your resolver without going through the graphql parsing.
  • handler serialize the data it gets and returns it back.
  • we can provide (just like AroundFields) a way for people to transform the results into REST results (status codes, etc)

What do you guys think? This way we can simply write a service in GraphQL, and then it can also expose REST, (and potentially also generate grpc as well)

Contributor Guide