Skip to content

Commit b3b32ae

Browse files
committed
add docs
1 parent ffe7b79 commit b3b32ae

File tree

9 files changed

+1325
-336
lines changed

9 files changed

+1325
-336
lines changed

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Usage
2+
3+
```
4+
yarn add apollo-trace-viz
5+
```
6+
7+
Ensure your graphql server is returning valid [apollo-trace](https://github.com/apollographql/apollo-tracing) extensions. Then pass the response to apollo-trace-viz.
8+
9+
And it'll print a visualization of your response. After drawing the visuals to the console it returns the response so you can chain it with other promise handlers.
10+
11+
![screenshot](./screen-shot.png)
12+
13+
## Example
14+
15+
```javascript
16+
const viz = require('apollo-trace-viz')
17+
const { GraphQLClient } = require('graphql-request')
18+
19+
const client = new GraphQLClient('https://fakerql.com/graphql', {
20+
headers: {
21+
'x-apollo-tracing': 1,
22+
},
23+
})
24+
25+
client
26+
.rawRequest(
27+
`{
28+
allUsers {
29+
id
30+
}
31+
}`,
32+
)
33+
.then(viz)
34+
.catch(console.error)
35+
```

data.json

-222
This file was deleted.

examples/index.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const viz = require('apollo-trace-viz')
2+
const { GraphQLClient } = require('graphql-request')
3+
4+
const client = new GraphQLClient('https://fakerql.com/graphql', {
5+
headers: {
6+
'x-apollo-tracing': 1,
7+
},
8+
})
9+
10+
client
11+
.rawRequest(
12+
`{
13+
allUsers {
14+
id
15+
}
16+
}`,
17+
)
18+
.then(data => viz(data))
19+
.catch(console.error)

examples/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "apollo-trace-viz-examples",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"dependencies": {
7+
"graphql-request": "^1.8.2",
8+
"apollo-trace-viz": "*"
9+
}
10+
}

0 commit comments

Comments
 (0)