graphql-python / graphql-python/graphene
Support converting graphene types to graphql-core types for better interop
- Lingua principale
- Python
- Stelle
- 8.2k
- Fork
- 818
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**Is your feature request related to a problem? Please describe.**
I don't want to buy-in into Graphene as framework, and I might like to convert some parts of my GraphQL server to Graphene without converting ALL of my graphql-related code to Graphene.
**Describe the solution you'd like**
I'd like Graphene to support something like `graphene_object_type.as_graphql_core_type()`.
@jkimbo says that it's not currently possible because "type generation code in graphene is stateful", but that it might be possible in the future.
**Describe alternatives you've considered**
I don't see any other pathways to the interop between different graphql libraries.
**Additional context**
Here's a question I asked on graphene slack:
> Hi everyone, I have a general question about python graphql libraries, hope this is the right channel to ask.In the last few months I tried Graphene first, then refactored everything to Ariadne and then recently refactored everything again to the raw graphql-core APIs because I wasn't happy with SDL-first approach.Right now I enjoy my lightweight graphql-core wrappers more than Graphene, Ariadne or Strawberry, so I thought that maybe I should upload them on PyPI. (I probably won't be able to maintain them well enough, but still. Maybe I will, it's worth a try.)But before I do that, I realized that I have a question that I don't fully understand: why do all three well-known python graphql libraries behave like frameworks? In a sense that they reinvent graphql-core objects hierarchy and replace them with their own wrappers which don't play well with others. I feel like this is sub-optimal, because it requires me to do the complete refactoring of my code if I want to adopt any of those, when I could just gradually replace parts of my code with Strawberry's dataclasses or Graphene's Django helpers, if those were presented as graphql-core compatible objects.I think I know two parts of the answer to my question:
>
> 1. Circular imports are tricky (but this can be solved with graphql-core's lambda feature, fields=build_fields and deferred imports in build_fields() body).
> 2. Ariadne (and probably others? my memory of Graphene and Strawberry's APIs is a bit lazy) provides a nice way to "register" your types and queries so that you don't have to stitch your final schema by hand with tons of imports and can reference other parts of your graph by names and not by type objects. In other words, they provide dependency injections.
>
> But so far, at least in my experience, both of these reasons turned out to be quite minor and fixable.So, what do you think? Does Python world need a "graphql library" as an alternative to "graphql frameworks"? Why or why not?
(@jkimbo asked me to create a feature request for this in the following discussion)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start by reviewing Graphene's type-generation behavior and the graphql-core object model, especially the stateful generation concern described in the issue. Define what conversion should cover and how callers would use it; the work is done when Graphene types can interoperate with graphql-core types without requiring a full framework migration.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- graphql, python
- Ambito
- api, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 30/100