Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Queries fail to return if sub-relation table has real world amount of data

Offen
#237 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
graphql, python, sqlalchemy

Rechercherichtung

Beginne mit graphene/types/resolver.py, insbesondere mit attr_resolver, und reproduziere die im Issue gezeigte verschachtelte tableA/tableB-Abfrage anhand einer großen verwandten Tabelle. Verfolge, wie das Auflösen von TableA dazu führt, dass auf die TableB-Beziehung zugegriffen wird, und überprüfe anschließend, dass die Abfrage innerhalb einer angemessenen Zeit zurückkehrt, ohne die gesamte verwandte Tabelle zu laden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

In a one to many if you have a table setup as follows (a very simple one to many relationship), the GraphQL query will timeout if tableB has any real world amount of data.

TableB has about 400k records in total. Graphene-sqlalchemy will query for TableA, and then SQLAlchemy itself will try resolve the relationship of the table when graphene calls for it. When this happens the query is sent to the DB but it won't return in enough time (its pulling back ~1GB of data as it tries to pull every single field on the sub table).

I've narrowed it down to graphene/types/resolver.py

def attr_resolver(attname, default_value, root, info, **args):
    return getattr(root, attname, default_value)

Graphene captures the TableA information, and then when TableB get resolved, the root parameter is populated with the "TableA" model, which SQLAlchemy then tries to completely resolve 400k records, query times out and then fails.

query{
  tableA(first: 10){
    edges{
      node{
        tableB(first: 5){
          edges{
            node{
              fieldA
            }
          }
        }
      }
    }
  }
}
Vorherrschende Sprache
Python
Sterne
984
Forks
224
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus graphql-python/graphene-sqlalchemy

Alle Issues in graphql-python/graphene-sqlalchemy

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.