Skip to content

Commit 2da1138

Browse files
Update README file with instructions on how to test the stub
1 parent de85a4a commit 2da1138

File tree

7 files changed

+74
-55
lines changed

7 files changed

+74
-55
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ npm test
2424
npm run specmatic:stub
2525
```
2626

27+
### Testing the Specmatic stub
28+
29+
Use the following curl commands to test if the stub is working as expected -
30+
31+
1. Simple query
32+
```shell
33+
curl -X POST http://localhost:8080/graphql \
34+
-H "Content-Type: application/json" \
35+
-d '{
36+
"query": "query { findAvailableProducts(type: gadget, pageSize: 10) { id name inventory type } }"
37+
}'
38+
```
39+
40+
2. Query with variables
41+
```shell
42+
curl -X POST http://localhost:8080/graphql \
43+
-H "Content-Type: application/json" \
44+
-d '{
45+
"query": "query FindAvailableProducts($type: ProductType!, $pageSize: Int!) { findAvailableProducts(type: $type, pageSize: $pageSize) { id name inventory type } }",
46+
"variables": {
47+
"type": "gadget",
48+
"pageSize": 10
49+
}
50+
}'
51+
```
52+
2753
### Start the application
2854

2955
```shell

graphl_examples/createProduct.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

graphl_examples/findAvailableProductsTest.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

graphql_examples/createProduct.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
request:
2+
body: |
3+
mutation {
4+
createProduct(newProduct: {
5+
name: "The Almanac",
6+
inventory: 10,
7+
type: book
8+
}) {
9+
id
10+
name
11+
inventory
12+
type
13+
}
14+
}
15+
response:
16+
{
17+
"id": "10",
18+
"name": "The Almanac",
19+
"inventory": 10,
20+
"type": "book"
21+
}
22+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
request:
2+
body: |
3+
query {
4+
findAvailableProducts(type: gadget, pageSize: 10) {
5+
id
6+
name
7+
inventory
8+
type
9+
}
10+
}
11+
response: [
12+
{
13+
"id": "10",
14+
"name": "The Almanac",
15+
"inventory": 10,
16+
"type": "book"
17+
},
18+
{
19+
"id": "20",
20+
"name": "iPhone",
21+
"inventory": 15,
22+
"type": "gadget"
23+
}
24+
]

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "react-scripts test --coverage --detectOpenHandles --forceExit --transformIgnorePatterns \"node_modules/(?!axios)/\"",
2727
"eject": "react-scripts eject",
2828
"graphiql": "node graphiql-server.js",
29-
"specmatic:stub": "java -jar node_modules/specmatic-beta/graphql/specmatic-graphql-all.jar stub --port 8080",
29+
"specmatic:stub": "java -jar node_modules/specmatic-beta/graphql/specmatic-graphql-all.jar virtualize --port 8080 --examples=graphql_examples",
3030
"test-ci": "cross-env SPECMATIC_LOG_LEVEL=debug DEBUG=specmatic-order-graphql-ui-react:* npm run test"
3131
},
3232
"eslintConfig": {

0 commit comments

Comments
 (0)