Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeDef to Schema? #36

Open
hoseyjoe opened this issue Dec 7, 2018 · 1 comment
Open

TypeDef to Schema? #36

hoseyjoe opened this issue Dec 7, 2018 · 1 comment

Comments

@hoseyjoe
Copy link

hoseyjoe commented Dec 7, 2018

Using a lot of typedefs in code already. Would it be easy to convert typedef to a schema?

@jcward
Copy link
Owner

jcward commented May 7, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants