Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Automatically infer Type of Queries

Open
#373 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start by tracing the named .select(), DSLQuery, and dsl_gql entry points to understand how schema return types are currently handled. Compare the requested countries/name and nested continent/name examples with the existing selection behavior, then define and test the expected generated GraphQL for scalar and object selections.

Written by the indexing model from the issue text.

Description

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

Dominant language
Python
Stars
1.7k
Forks
195
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from graphql-python/gql

All issues in graphql-python/gql

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.