Hi folks, I am looking at interfacing with prefect’s graphql API using Typescript and was wondering if the schema for Prefect’s API is available anywhere? Ideally I’d like to autogenerate typescript types for the queries, mutations etc. I’ve tried using
graphql-code-generator
but that hasn’t worked so far
Eddie Atkinson
10/22/2021, 9:12 AM
That’s the output from
graphql-codegen
a
Anna Geller
10/22/2021, 9:18 AM
@Eddie Atkinson In the UI, there is an interactive API with documentation explorer - you can use it to look up any schema, and write your queries and mutations:
e
Eddie Atkinson
10/22/2021, 9:23 AM
I was hoping for something less manual. Ideally I’d like to interface with prefect without having to write and maintain queries and mutations. It would be cool to be able to generate the schema for prefect as part of my CI/CD pipeline
a
Anna Geller
10/22/2021, 9:36 AM
@Eddie Atkinson can you describe your use case a bit more? What are you trying to do with Prefect API? I don’t understand what problem are we solving here. Are you looking for auto-completion based on the API schema in your IDE? the CI/CD part confused me the most 🙂
e
Eddie Atkinson
10/25/2021, 12:07 AM
Hi @Anna Geller, sorry for disappearing over the weekend. I am looking at creating a set of lambda functions in Typescript to interact with Prefect (the lambda functions are part of a REST API for a front-end) which are used to trigger flow runs etc. I was hoping to auto generate the types for the mutations, queries etc from the Prefect graphql API, but was struggling with the fact that the API is authenticated
Eddie Atkinson
10/25/2021, 12:08 AM
For anyone else who struggles with this, this resource from Hasura was very helpful. This is the
codegen.js
file I used to generate the types for the Prefect API:
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.