GithubHelp home page GithubHelp logo

Comments (14)

mweststrate avatar mweststrate commented on May 19, 2024 3

For example: https://github.com/dotansimha/graphql-code-generator

from mst-gql.

jamonholmgren avatar jamonholmgren commented on May 19, 2024 3

@RXminuS npx gluegun new mst-gql --typescript will get you set up with an initial TypeScript boilerplate. Hit me up if you run into problems. I'm happy to knock out bugs fast on Gluegun. I just released 4.0.0 which needs more testing, so let me know. Also any documentation gaps.

from mst-gql.

swyxio avatar swyxio commented on May 19, 2024 2

@jamonholmgren's https://github.com/infinitered/gluegun does templating well.

from mst-gql.

mweststrate avatar mweststrate commented on May 19, 2024 2

from mst-gql.

RXminuS avatar RXminuS commented on May 19, 2024 1

Ok, but then I'll give it a shot with Gluegun next week. I'll probably first just spit out a few ejs templates not worrying too much about the actual data. And then put up a bit cleaner framework for the CLI & logging. Hopefully, then others can join in to help fill in the actual template data as I expect that requires a bit of knowledge of how it is currently generated.

I would prefer writing everything in Typescript if that's ok with everyone?

from mst-gql.

jamonholmgren avatar jamonholmgren commented on May 19, 2024

Thanks for the mention, @sw-yx!

We're using the ejs library to power our template system:

https://github.com/infinitered/gluegun/blob/b35a848c1cf5324f7767d15104416d8a78b2035b/src/toolbox/template-tools.ts#L16

We also have a really cool patching library:

https://github.com/infinitered/gluegun/blob/b35a848c1cf5324f7767d15104416d8a78b2035b/src/toolbox/patching-tools.ts

Both are built-in to Gluegun, which may be overpowered for your needs here. But if you want to make mst-gql a full featured CLI, let me know and I can walk you through what you get with Gluegun! Otherwise, feel free to steal/borrow any concepts from the links I posted here.

from mst-gql.

danielkcz avatar danielkcz commented on May 19, 2024

Should we actually turn this into a monorepo to split stuff into plugins? I am no big fan of Lerna, it does the job, but it also gets in the way fairly often.

from mst-gql.

mweststrate avatar mweststrate commented on May 19, 2024

from mst-gql.

danielkcz avatar danielkcz commented on May 19, 2024

Ok sure, I suppose that Gluegun can use "plugins" from the single package, so that shouldn't matter, but we should also support custom plugins from NPM.


Regarding the code generation, I actually do have a custom generator for graphql-code-generator which generates fully typed hooks for each graphql operation. I am not sure yet how it would look like here, but a similar alternative would be really nice.

export function useQResolveLocation(
  variables?: QResolveLocationVariables,
  baseOptions?: Hooks.QueryHookOptions<QResolveLocationVariables>,
) {
  return Hooks.useQuery<QResolveLocationQuery, QResolveLocationVariables>(
    QResolveLocationDocument,
    variables,
    baseOptions,
  )
}

I am using prefixes Q, M, S, F for my *.gql documents and based on that I can distinguish those easily.

from mst-gql.

dpnolte avatar dpnolte commented on May 19, 2024

I just want to add that kotlin/java poet might be a good source of inspiration: https://github.com/square/javapoet and https://github.com/square/kotlinpoet . I love that library. It uses builders to generate the code, instead of dealing with a template engine. The builders take care of indentation, importing types and injecting formatted variables with c-style literals. Writing code generator logic can get quite messy quickly, and java poet does a great job of keeping it under control. Unfortunately, I didn't find any equivalents in JS. The most similar lib that I've found so far was ts-morph

from mst-gql.

RXminuS avatar RXminuS commented on May 19, 2024

Would love to help out with this.

Gluegun definitely looks promising (especially the patching could be great). I've also used Plop which was quite simple to understand and Hygen looks promising.

@dpnolte ts-morph looks like "the proper way" that you would want to do code generation by using the AST. However, reasoning about AST's gets quite complex quickly and can be difficult for newcomers to understand. Since most of the code will be auto-generated and provide convenient hooks for people to extend it means we already have a great deal of control over some of the foundational assumptions and as such we could just work on those with simpler file templating and "patch comments" for us to use.

I think we should make a decision on this rather soon before we end up adding a bunch of code that becomes difficult to port. @mweststrate did you already have a direction in mind?

from mst-gql.

mweststrate avatar mweststrate commented on May 19, 2024

from mst-gql.

chrisdrackett avatar chrisdrackett commented on May 19, 2024

yes please on typescript :)

from mst-gql.

beepsoft avatar beepsoft commented on May 19, 2024

@RXminuS do you have any progress with this?

I myself would like to have the options provided by https://graphql-code-generator.com/docs/plugins/typescript, which allow changing the case of type names/enums and getting rid of underscores in type names in generated code.

It uses a configuration like this:

config:
  namingConvention:
    typeNames: change-case#pascalCase
    transformUnderscore: true

I thought I add such options to the current generator but if there's already a better one in progress I would rather work with that.

from mst-gql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.