kgoggin / graphql-codegen-reason Goto Github PK
View Code? Open in Web Editor NEWA GraphQL Codegen plugin to generate ReasonML types
A GraphQL Codegen plugin to generate ReasonML types
Current Version of @graphql-codegen/cli does not work and will present the following on generating:
Found 1 error
✖ src/GraphQLTypes.re
Error: Cannot use GraphQLDirective "@include" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
It looks like version 1.5.0 of codegen now uses "graphql": "^15.5.0", which is resulting in this error.
Should be able to internalize the helper functions so we've got one less dependency.
Currently if there's an issue with decoding the JSON, I'm Js.log
ing the problem and throwing a generic Not_found
exception. It'd be better to have a specific exception that gets thrown with better error messages.
If documents
is present and option is set to true
, this would filter the list of input types down to only the ones actually being used in a query/mutation operation.
Hi @kgoggin !
We recently found your repository, and we saw you did an awesome work on creating a Reason plugin for the codegen.
We added it to our list of plugins (dotansimha/graphql-code-generator#1326), and added it to the codegen's website (https://graphql-code-generator.com/docs/plugins/).
Thank you for using the codegen. It would be great to meet and discuss about it if you wish :)
Update README.md to alert the fact that __typename
field must be present in each fetched object.
Update the code and deps to v1.0 of the underlying plugin system.
I tried running your project against the swapi-graphql schema. The schema and output can be see here: https://github.com/idkjs/graphql-codegen-reason/tree/master/tester. Side note: Only way I could get this to run is to run it on your master repo and switching out the schema. Installing the codegen per the instructions did not work for me. Probably just to thick in the head to understand your readme, but none the less.
Is this a bug or not an intended use case? Thanks for the feedback.
Running the codegen produces the following error:
>>>> Finish compiling(exit: 1)
>>>> Start compiling
[1/1] Building tester/generated/GraphQLTypes-GqlToReasonTester.cmj
We've found a bug for you!
/Users/prisc_000/working/graphql-codegen-reason-fork/tester/generated/GraphQLTypes.re 664:29-32
662 │ let vehicle: field(t, option(vehicle)) =
663 │ getNullableField(~fieldName="vehicle", ~typename);
664 │ let node: field(t, option(node)) =
665 │ getNullableField(~fieldName="node", ~typename);
666 │ };
This type constructor's parameter, `node`, can't be found. Is it a typo?
>>>> Finish compiling(exit: 1)
Would this library work with ReScript?
Ran some random schemas to check it out. Great project, sir. Kept trying stuff until I got an error. Finally got one with this SpaceX schema
Steps:
npx fetch-graphql-schema https://yv004pqnq9.sse.codesandbox.io/graphql -o schema.graphql -r
schema: ./schema.graphql
generates:
GraphQLTypes3.re:
plugins:
- reason-client
config:
scalars:
"DateTime": "string"
Run: [master*]node_modules/.bin/gql-gen
Output.
server [master*]node_modules/.bin/gql-gen
✔ Parse configuration
❯ Generate outputs
❯ Generate GraphQLTypes3.re
✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ Generate
→ 1685: <syntax error>
Found 1 error
✖ GraphQLTypes3.re
[object Object]
How do we render that object object so we can chase it down?
Thanks. And thanks for sharing.
Currently the plugin isn't running refmt after generating the string, because it makes it harder to deal with any errors in the output.
This was helpful during development, but in most scenarios we probably want to make sure we actually format the code - we'll add an option to not run it for scenarios where it might be useful.
I'd like to have the Codegen also parse any Graphql Documents to extract the variables used in queries, and provide types for those as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.