Comments (14)
For example: https://github.com/dotansimha/graphql-code-generator
from mst-gql.
@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.
@jamonholmgren's https://github.com/infinitered/gluegun does templating well.
from mst-gql.
from mst-gql.
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.
Thanks for the mention, @sw-yx!
We're using the ejs
library to power our template system:
We also have a really cool patching library:
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.
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.
from mst-gql.
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.
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.
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.
from mst-gql.
yes please on typescript :)
from mst-gql.
@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)
- How do I update data from server? HOT 1
- before / after request query hooks
- useQuery is not reactive HOT 3
- How to intercept gql http errors. HOT 1
- Circular dependency on scaffolding HOT 1
- Query action takes more time than plain fetch request HOT 1
- yarn test:cra fails with TS errors HOT 1
- feat(config): Prefer gqlWsClient over gqlHttpClient when the client's Websocket is active HOT 1
- Discord server and better communication HOT 13
- types.late always typed as any HOT 1
- TypeError: Cannot read property 'endsWith' of undefined HOT 2
- Complex filters handling using generated code
- Is it possible to have local-only queries/mutations? HOT 4
- [name]ModelSelector requires passing 'undefined' instead of empty for non-primitive fields HOT 1
- Locally instantiated model causing "Failed to resolve reference" error
- Scaffolding tool breaks on multidimensional array types
- How to add HTTP header to one request? HOT 1
- Partial data returned is ignored?
- New maintainer HOT 2
- v0.17.2 is released
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mst-gql.