Generate TS types from schema

Hello,

We are currently migrating from JS to TS in our Parse Server GraphQL custom resolvers and Cloud code using @types/parse and I would like to know if there’s any way to generate typescript interfaces from our Parse Schema to benefit from class types ? I know that is not really related to Parse as it is written in JS but if you guys have any idea on how to do it this can help us. I was thinking of schema parser.

Thank you!

I am not aware of any existing tool but I believe that a lib to do that would be very helpful for Parse ecosystem.

Hi, thank for you answer.

I found this repo GitHub - open-inc/parse-server-schema that does exactly what I want)
It transforms a Parse Schema into TS types. I think that a lot can be added to.

Hi @antek ,

Also if you want to get a fully typed experience in you code (both server side and client side). You can use codegen tools to generate typed mutations/queries from GraphQL files and you Parse Server Auto Generated GraphQL Schema.

You can see an example here: https://github.com/Moumouls/parse-next-mono-starter/tree/master/packages/back

Steps:

  • Start your server
  • use a tool like “get-graphql-schema” to extract a schema.graphql from your server
  • create some .graphql files with some queries/mutations
  • run the codegen
  • then you have a graphql client that you can use on server side with master key to perform fully typed operations

GraphQL is a perfect API system to generate some types. Using GraphQL Codegen to generate mutations/queries with master key in you cloud code, allow a fully typed experience with Parse Server.

The codegen architecture is also usable on front end (without master key obviously)