Skip to content

Commit 08f82c6

Browse files
authored
[Style guide] Added section on graphql api explorer (#23204)
* [Style guide] Added secton on graphql api explorer * add headings
1 parent 9b4c4ca commit 08f82c6

File tree

1 file changed

+56
-5
lines changed
  • src/content/docs/style-guide/components

1 file changed

+56
-5
lines changed

src/content/docs/style-guide/components/code.mdx

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Write-Output "This one has a title!"
1515
```js collapse={3-5}
1616
// Collapsing
1717
const foo = {
18-
1: 1,
19-
2: 2,
20-
3: 3,
18+
1: 1,
19+
2: 2,
20+
3: 3,
2121
};
2222
```
2323

@@ -80,11 +80,13 @@ index_name = "tutorial-index"
8080
```
8181
````
8282

83-
## Playground
83+
## Workers Playground
8484

8585
If you add the `playground` option to the opening code fence for a Worker example, it will
8686
add a "Run Worker in Playground" link that will take the user to the [Worker's playground](/workers/playground/)
8787

88+
### Live demo
89+
8890
```js playground
8991
export default {
9092
fetch() {
@@ -93,7 +95,9 @@ export default {
9395
};
9496
```
9597

96-
````mdx
98+
### How to use
99+
100+
````mdx "playground"
97101
```js playground
98102
export default {
99103
fetch() {
@@ -102,3 +106,50 @@ export default {
102106
};
103107
```
104108
````
109+
110+
## GraphQL API explorer
111+
112+
If you add the `graphql-api-explorer` option to the opening code fence for a `graphql` code block, it will
113+
add a "Run in GraphQL API Explorer" link that will take the user to the [GraphQL API explorer](https://graphql.cloudflare.com/explorer).
114+
115+
### Live demo
116+
117+
```graphql graphql-api-explorer title="A GraphQL query"
118+
query ASingleDatasetExample($zoneTag: string, $start: Time, $end: Time) {
119+
viewer {
120+
zones(filter: { zoneTag: $zoneTag }) {
121+
firewallEventsAdaptive(
122+
filter: { datetime_gt: $start, datetime_lt: $end }
123+
limit: 2
124+
orderBy: [datetime_DESC]
125+
) {
126+
action
127+
datetime
128+
host: clientRequestHTTPHost
129+
}
130+
}
131+
}
132+
}
133+
```
134+
135+
### How to use
136+
137+
````mdx "graphql-api-explorer"
138+
```graphql graphql-api-explorer title="A GraphQL query"
139+
query ASingleDatasetExample($zoneTag: string, $start: Time, $end: Time) {
140+
viewer {
141+
zones(filter: { zoneTag: $zoneTag }) {
142+
firewallEventsAdaptive(
143+
filter: { datetime_gt: $start, datetime_lt: $end }
144+
limit: 2
145+
orderBy: [datetime_DESC]
146+
) {
147+
action
148+
datetime
149+
host: clientRequestHTTPHost
150+
}
151+
}
152+
}
153+
}
154+
```
155+
````

0 commit comments

Comments
 (0)