miragejs / graphql

A library for handling GraphQL requests with Mirage JS
MIT License
74 stars 12 forks source link

Add ability to create POJO with model info from graphql schema #30

Closed josemarluedke closed 3 years ago

josemarluedke commented 3 years ago

Refactor the ensureModels function into a lower-level method that returns a POJO with all the model info and their associations. ensureModels then uses that lower-level function to add models to Mirage. Making this change a non-breaking change.

This new createModels function can be used to create models in a different way. My use case is to build a code generator that actually generates the code for Mirage Models from the GraphQL schema. The goal is to have all hardcoded models so folks using TypeScript can have these model definitions for type checking.

jneurock commented 3 years ago

Thanks for the PR! Sounds really handy for TS users. Do you feel like we should add the code generator to this lib?

josemarluedke commented 3 years ago

@jneurock Thanks for the review. I appreciate the fast feedback. I have pushed the changes. I did add a few more tests and kept the tests for the mirage relationships. Let me know what you think, if you want I can defiantly remove that.

About the codegen, I will be creating a new project as a plugin for the graphql-code-generator, but I believe the plugin needs to be the entrypoint for the package.

jneurock commented 3 years ago

@jneurock Thanks for the review. I appreciate the fast feedback. I have pushed the changes. I did add a few more tests and kept the tests for the mirage relationships. Let me know what you think, if you want I can defiantly remove that.

About the codegen, I will be creating a new project as a plugin for the graphql-code-generator, but I believe the plugin needs to be the entrypoint for the package.

Thanks for explaining and introducing me to something new! That's really cool. I haven't heard of the code generator and a plugin for this makes total sense.