haxe-graphql
haxe-graphql copied to clipboard
TypeDef to Schema?
Using a lot of typedefs in code already. Would it be easy to convert typedef to a schema?
Hey, sorry I missed this note. Yeah, the Haxe typedef representation is really similar to the GQL type definition -- well, at least for simple-ish types. For example, if you enter this schema into the online demo:
type Rating {
author:String!
srats:Int!
}
type FilmData {
id:ID!
title:String!
director:String
ratings:[Rating]
}
You'll get this Haxe output:
/* - - - - Haxe / GraphQL compatibility types - - - - */
abstract ID(String) to String from String { }
typedef Rating = {
author : String,
srats : Int,
}
typedef FilmData = {
id : ID,
title : String,
?director : String,
?ratings : Array<Rating>,
}
It might not be difficult to convert by hand, or with a simple script.
Now, representing Haxe types in GQL introduces build complexity and more limited capabilities (in GQL than Haxe), so you need to have a reason to do it. e.g. some other part of your application wants those GQL definitions.