Automatically infer Type of Queries
还没有人认领这个 Issue。
评估
调研方向
首先跟踪列出的 .select()、DSLQuery 和 dsl_gql 入口点,以了解当前如何处理 schema 返回类型。将请求的 countries/name 和嵌套 continent/name 示例与现有的选择行为进行比较,然后定义并测试标量选择和对象选择所应生成的 GraphQL。
由索引模型根据 Issue 内容生成。
描述
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
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-python/gql 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
graphql-python/gql#613 · 2 条评论 ·
-
type: feature
难度 3/5 1-2 天 新手友好度 42/100
graphql-python/gql#434 ·
-
type: feature
难度 3/5 1-2 天 新手友好度 42/100
graphql-python/gql#355 · 1 条评论 ·
-
type: feature
难度 5/5 一周以上 新手友好度 25/100
graphql-python/gql#316 · 5 条评论 · 3 个 reaction ·
查看 graphql-python/gql 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
vllm-project/vllm-metal#822 ·
维护者通常 1 天内回复
-
vector-store
难度 1/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFile未关闭
难度 2/5 1-3 小时 新手友好度 78/100
BasedHardware/omi#19047 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复