graphql-python / graphql-python/graphene

Support converting graphene types to graphql-core types for better interop

オープン
#1,238 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
✨ enhancement
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

説明

**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)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、Graphene の型生成の動作と graphql-core のオブジェクトモデルを確認します。特に、issue で説明されている状態を持つ生成に関する懸念を確認してください。変換で対象とすべき範囲と、呼び出し側がそれをどのように使用するかを定義します。Graphene の型が、フレームワーク全体の移行を必要とせずに graphql-core の型と相互運用できるようになれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
graphql, python
領域
api, backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。