Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Automatically infer Type of Queries

未关闭
#373 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

首先跟踪列出的 .select()、DSLQuery 和 dsl_gql 入口点,以了解当前如何处理 schema 返回类型。将请求的 countries/name 和嵌套 continent/name 示例与现有的选择行为进行比较,然后定义并测试标量选择和对象选择所应生成的 GraphQL。

由索引模型根据 Issue 内容生成。

描述

type: feature

For the following query on https://countries.trevorblades.com/

query GetCountries {
  countries {
    name
  }
}

The snippet to generate this dynamically using gql is:

dsl_gql(
    GetCountries=DSLQuery(
        ds.Query.countries.select(ds.Country.name)
    )
)

Notice that in the raw graphql I just mentioned name instead of Country.name. As the schema already lays out the return types of all queries, graphql is able to figure it out automatically.

""" schema.graphql """
type Query {
...
  countries(filter: CountryFilterInput): [Country!]!
...
}

type Country {
...
  name: String!
...
}

Would it be possible to modify .select() to auto-select objects of the query type by their name?
Maybe something like:

dsl_gql(
    GetCountries=DSLQuery(
        ds.Query.countries.select("name", DSLAutoSelectable("continent").select("name"))
    )
)

Resulting graphql

query GetCountries {
  countries {
    name
    continent {
      name
    }
  }
}

Note: The sgqlc library has a __fields__() method which can get the immediate scalars by name: https://github.com/profusion/sgqlc/blob/465a5e800f8b408ceafe25cde45ee0bde4912482/sgqlc/operation/__init__.py#L390

主要语言
Python
星标
1.7k
派生
195
平均合并
14 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphql-python/gql 的其他 Issue

查看 graphql-python/gql 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。