graphql-python / graphql-python/graphene
Support converting graphene types to graphql-core types for better interop
- Langage dominant
- Python
- Étoiles
- 8.2k
- Forks
- 818
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
**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)
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par examiner le comportement de génération de types de Graphene et le modèle objet de graphql-core, en particulier le problème de génération avec état décrit dans l’issue. Définissez ce que la conversion doit couvrir et comment les appelants l’utiliseraient ; le travail est terminé lorsque les types Graphene peuvent interopérer avec les types graphql-core sans nécessiter une migration complète du framework.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- graphql, python
- Domaine
- api, backend-api-design
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 30/100