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.
1
github.com/mirumee/ariadne-codegen sounds like exactly what you want – was it a different one you tried?
55 mins ago