graphqxl icon indicating copy to clipboard operation
graphqxl copied to clipboard

[WIP] Take one at getting a working nodejs build where you can convert string to strings using the napi

Open orta opened this issue 7 months ago • 3 comments

This may end up on the discard pile, but I at least felt I should try get some incremental work out there. I've not shipped any rust code, so assume the worst. My goal is to make a nodejs API, so I can use this library in-memory in my own code.

To do that, I've added a new subcrate which exposes a single function to napi, I could get it to correctly build using cargo, and most of the way using napi build it just seems to fail at a linker stage - but I ran out of time and figured I could come back to it later on in the week

But maybe it's something you're into, and/or its something you've done before - so no pressure, I'll take a stab later on regardless

orta avatar May 26 '25 20:05 orta

This route won't work anyway, because of features like import requiring fs access, if I want to do this in-memory, I'm going to need to have an API which uses a JS vfs object instead - https://github.com/gabotechs/graphqxl/compare/main...orta:graphqxl:napi-2?expand=1 is my WIP on that, and being a lot more strict with the napi template to this codebase transition

orta avatar May 27 '25 09:05 orta

Very interesting! I do not have much experience with this, I imagine that the fact that this library is directly accessing the file system using std could complicate things?

Happy to see what comes out of this 🍿

gabotechs avatar Jun 03 '25 08:06 gabotechs

OK, so I've come back at this with Claude Code and got a solid working build which is deployed to npm:

import { graphqxlToSdl } from "@orta/graphqxl";

const vfs = {
  "schema.graphqxl": `
    import "user"
    import "post"
    
    type Query {
      user(id: ID!): User
      users: [User!]!
      post(id: ID!): Post
      posts: [Post!]!
    }
  `,
  "user.graphqxl": `
    type User {
      id: ID!
      name: String!
      email: String!
      posts: [Post!]!
    }
  `,
  "post.graphqxl": `
    type Post {
      id: ID!
      title: String!
      content: String!
      author: User!
    }
  `,
};

const sdl = graphqxlToSdl(vfs, "schema.graphqxl");
console.log(sdl);
❯ node index.mjs
type User {
  id: ID!
  name: String!
  email: String!
  posts: [Post!]!
}

type Post {
  id: ID!
  title: String!
  content: String!
  author: User!
}

type Query {
  user(id: ID!): User
  users: [User!]!
  post(id: ID!): Post
  posts: [Post!]!
}

That said, the build and deployment setup for this thing is extensive. You'd probably have to be actively interested in shipping to node as a feature before even considering merging. Even then, you may be better off re-creating from scratch with the right package names, repo references, GitHub workflows etc.

I based it off working with https://napi.rs

https://github.com/gabotechs/graphqxl/compare/main...orta:graphqxl:napi-3?expand=1

orta avatar Jun 15 '25 17:06 orta