Skip to content

Operation codegen does not find variables with DataHub graphql code #236

@J0hnG4lt

Description

@J0hnG4lt

🐜 Bug Report

I get the following errors related to GraphQL variables:

(datahub) georvic@georvic-IdeaPad-3-15ITL6:~/repos/datahub-metadata$ sgqlc-codegen operation my_schema ./operations/search.py /home/georvic/repos/datahub/datahub-web-react/src/graphql/search.graphql
no variable named 'includeAssertions' at /home/georvic/repos/datahub/datahub-web-react/src/graphql/search.graphql:831:64

and

(datahub) georvic@georvic-IdeaPad-3-15ITL6:~/repos/datahub-metadata$ sgqlc-codegen operation my_schema ./operations/lineage.py /home/georvic/repos/datahub/datahub-web-react/src/graphql/lineage.graphql
no variable named 'separateSiblings' at /home/georvic/repos/datahub/datahub-web-react/src/graphql/lineage.graphql:246:93

Here are the links to the files in question:

Expected Behavior

The Python scripts with operations should be generated without these errors.

Current Behavior

The two errors above appear and the two output Python scripts remain empty.

Possible Solution

I'll try to debug more this when I have time.

Edit:

The issue went away after moving the queries to the top, before the fragments.

Steps to Reproduce

  1. pip install sgqlc==16.2 graphql-core==3.2.3 # with Python 3.7.16
  2. git clone https://github.com/datahub-project/datahub.git
  3. sgqlc-codegen operation my_schema ./search.py ./datahub/datahub-web-react/src/graphql/search.graphql
  4. sgqlc-codegen operation my_schema ./lineage.py ./datahub/datahub-web-react/src/graphql/lineage.graphql

Context (Environment)

I'm trying to auto-generate a Python client to access DataHub's GraphQL endpoints. In the past, it's been difficult to deal with this without implementing my own complicated Python packages. I believe that sgqlc has the potential to simplify a good amount of issues I've faced with DataHub in this regard.

I gave more context on this in the official DataHub Slack account: https://datahubspace.slack.com/archives/C02QMLWJG12/p1687255354060359

imagen

So far, using sgqlc seems the most promising approach!

These two errors, and other one that was fixed by this PR, are the only problems I've encountered so far. All the other operation scripts have been generated successfully. I could re-write the graphql code used by DataHub in my own package, but it would be nice if the library itself can handle it (because it's valid code in any case).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions