Tools for using Haxe + GraphQL

Hi Haxe friends,

Here’s a new screenshot of my Haxe + GraphQL project that my company, wootmath.com, plans to open source soon:

If you widen the window, you can see the parser step, too. It’s built on top of @back2dos tink_parse lib.

Overall, it’s very alpha. Lots to work out still. Here’re are the bits I’m planning / building - above is the webdemo powered by parser+hxgen.

image

No progress on the macro workflow yet.

I’m going to offer an option to generate either typedefs or interfaces + classes. I believe they both technically work, it just depends on how you want to work with (and instantiate) your data (as class instances, or typed structs.)

This only deals with mapping simple schema / type definitions at the moment. Not yet any GraphQL queries, arguments, fragments, servers, etc. But it’s a nice, tidy interface description language, so we’re minimally looking into it for cross-stack data type definitions.

Cheers,
-Jeff

12 Likes

wow graphql with haxe , really hope this progress , so i can combine it with gatsbyjs

I guess it’s using the JS client (Relay?) to query the data right?

So far, I’m just working on basic schema / type mapping. Later I’ll look into typing queries. Once Haxe has all the correct types from a .graphql schema, I assume that you’d typically compile to JS and use the JS servers / etc.

That is, I don’t plan on building a server / query implementation in Haxe. Just the type definitions, so Haxe can be easily integrated with graphql-specified systems.

Not suggesting the server, but the client side requires quite a heavy logic.

Well, that’s got me thinking “server / queries”. As I mentioned up top, all I’m focused on so far is graphql schema / type definitions. :slight_smile:

But… what is shown above is 100% in Haxe, no JS dependencies.

Without a client at least it’s a bit senseless, no?

I don’t think so. That’d be like saying externs are useless because they don’t do anything.

Schema / type definitions are a small piece of the graphql ecosystem, but it is the foundation. You have to start somewhere! Or, looking at the graphql homepage… this project is currently in this realm:

Even besides the type definition generation, this repo has nice, small, digestible examples of:

  • a repo that delivers an npm module and a haxelib, from Haxe source
  • a small web editor demo that uses highlight.js
  • a parser built on tink_parse (I had a hard time finding simple examples)
  • a place to work together on Haxe + graphql tools & ideas
3 Likes

Very cool!
Any idea when the source will be public?

Probably this or next week.

Ok, I’ve gone ahead and published the bare bones project to: GitHub - jcward/haxe-graphql: Utilities for working with Haxe and GraphQL.

NPM package: https://www.npmjs.com/package/gql2hx

No haxelib yet (see issue describing planned macro workflow)…

Also, I’ve created an issue to discuss expanding beyond schema / other use cases - feel free to add to that thread.

2 Likes

FYI, I got tired of implementing a fragile parser clone, so I ported the official v0.13.2 graphql-js parser (parser.js, lexer.js, and ast.js). For the curious, I devised a few dozen regex’s in Ruby scripts, and it took about a day.

Naturally, this closes a bunch of issues and makes this library a ton more stable.

image

Also, expected query result types are now being generated – have a play with the updated web demo example:

image

2 Likes

I’ve been working on a way to simplify working with aws AppSync and haxe (one click to full project up and running goal). This graphql parser was the missing link between haxe and Apollo. Thanks!

A working demo is here: Todo App

The graphql parts of the code are here: amazonian/TodoView.hx at master · Randonee/amazonian · GitHub

It’s basically doing what graphql-tag does, creates graphql AST and passes it to an Apollo function.

Code for the whole thing is here:

1 Like

I am looking forward to building a Haxe implementation of prisma.io with this library. Good work @jcward

1 Like