Install the node packages for this project.
npm install
npm install git+https://github.com/znsio/specmatic-node-beta.git#4309b14
Note - Pick up the version (#4309b14) from package.json
npm test
npm run specmatic:stub
Use the following curl commands to test if the stub is working as expected -
- Simple query
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "query { findAvailableProducts(type: gadget, pageSize: 10) { id name inventory type } }"
}'
- Query with variables
curl -X POST http://localhost:8080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "query FindAvailableProducts($type: ProductType!, $pageSize: Int!) { findAvailableProducts(type: $type, pageSize: $pageSize) { id name inventory type } }",
"variables": {
"type": "gadget",
"pageSize": 10
}
}'
npm start
This should automatically start the application and pull it up in your browser.
npm run graphiql
You can now open GraphiQL in your browser and test out some GraphQL queries.
This instance of GraphiQL has been setup to query the Specmatic stub instance running on http://localhost:4000/graphql.