Dynamic Python Function Generation from GraphQL Schema for API Requests

Dynamic Python Function Generation from GraphQL Schema for API Requests


0

I’m looking for a method to dynamically generate Python functions that correspond to the queries and mutations defined in a GraphQL schema. After obtaining the schema, I want a system that can automatically create these functions, so I can simply import the generated code into my Python project and call the functions with the necessary parameters.

The ideal solution would facilitate seamless interactions with the GraphQL API by abstracting the request construction process. It would allow for changes in the schema without the need for manual updates to the function definitions in the client code.

Could you provide advice on tools or libraries that support this functionality, or point me towards a process that would allow for this level of automation? If there are existing best practices or patterns, especially those that cater to Python’s asynchronous features, I would greatly appreciate learning about them.

I haved tried ariadnegraphql code generator but I had to specify a query like this:

query MyQuery {
    getCar(plate_number: "14-77-ER") {
      addresses
      brand
      mongoObjId
    }
}

and it created an Client for this query with fix params.

New contributor

b8511 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *