Usage
version: "3"
services:
mocker:
image: mongoke/graphql-mocker
ports:
- 7090:80
environment:
- PORT=80
- URL=http://gqlapi:8080/graphql
- MOCKS_PATH=/mocks.js
- PRESERVE_MUTATIONS=1
# maintain mutations from original schema
- PRESERVE_QUERIES=allAssets, queryName
# maintain certain queries
volumes:
- ./tests/mocks.js:/mocks.js
gqlapi:
ports:
- 7060:8080
build: your api
Usage as cli
Install
npm install -g graphql-easy-mocks
Then run
graphql-easy-mocks --port 9000 -f schema.graphql -m mocks.js
// mocks.js const faker = moduleexports = 'works!' fakerrandom
Then start the server with the app
"scripts":
Then use it as your server url inside your app.
const uri = processenvREACT_APP_TESTING ? 'http://localhost:9000' : 'https://countries.trevorblades.com'