Skip to content

A GraphQL server that mocks response based on a JSON schema

License

Notifications You must be signed in to change notification settings

lemuelbarango/graphql-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-mock

A mock GraphQL server that responds based on any GraphQL JSON schema. It can be used when testing a client that queries a GraphQL API.

It uses the apollo graphql tools library and faker.js library, to generate fake responses.

Usage

# run
docker run  -p 4000:4000 lemuelbarango/graphql-mock

To use custom GraphQL schema

docker run  -p 4000:4000 \
-v [PATH_TO_SCHEMA_JSON]:/server/dist/schema.json \
lemuelbarango/graphql-mock

# Also accepts schema URL as an env variable
docker run  -p 4000:4000 \
-e SCHEMA_URL='https://raw.githubusercontent.com/lemuelbarango/graphql-mock/master/src/schema.json' \
lemuelbarango/graphql-mock

To override mock values with example mock.json

// name.firstName is a property from faker.js
{
  "Person": {
    "name": "name.firstName"
  }
}
docker run  -p 4000:4000 \
-v [PATH_TO_MOCK_JSON]:/server/dist/mock.json \
lemuelbarango/graphql-mock

The default Docker ENTRYPOINT listens on port 4000 for HTTP

About

A GraphQL server that mocks response based on a JSON schema

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published