graphql-kit / graphql-faker

🎲 Mock or extend your GraphQL API with faked data. No coding required.
MIT License
2.68k stars 225 forks source link

Resolving Query Without Server (for generating mocks) #121

Open a-laughlin opened 4 years ago

a-laughlin commented 4 years ago

Love the project! Looking to generate mocks for testing client state. Is there any way to render query output to a file without starting the server? It looks like graphqlHTTP is the only query api currently.

IvanGoncharov commented 4 years ago

@a-laughlin Do you want a CLI flag for that or you want to use graphql-faker as a library in your framework?

a-laughlin commented 4 years ago

Simple and flexible is good. Perhaps a query function to generate various mocks on demand. e.g., "require('graphql-faker').query(, vars)". It might even be possible to use the graphql-js execute function as is.

CLI would be more complicated. Running 'node -e "require('graphql-faker').query(, vars)" would likely work good enough for cli scenarios, and allows optionally substituting fs.readFileSync to read queries from files.

On Wed, Jun 10, 2020, 11:34 PM Ivan Goncharov notifications@github.com wrote:

@a-laughlin https://github.com/a-laughlin Do you want a CLI flag for that or you want to use graphql-faker as a library in your framework?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/APIs-guru/graphql-faker/issues/121#issuecomment-642418612, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7HTZDUNILWIDWCJUNWZLRWBUHPANCNFSM4N23O7NA .

vitorcamachoo commented 3 years ago

@a-laughlin Do you want a CLI flag for that or you want to use graphql-faker as a library in your framework?

Through a library will be good!