Skip to content

Commit d090270

Browse files
Merge branch 'cloudflare:production' into krishnprakash/cloudflare-docs
2 parents 1d304c0 + aab964c commit d090270

File tree

81 files changed

+4584
-2795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4584
-2795
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist
55
public/__redirects
66
public/analytics/static/downloads/main.css
77
src/content/workers-ai-models/*.json
8+
src/content/partials/images/*.mdx

CONTRIBUTING.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,71 @@ export default {
9999
would render as
100100

101101
<img width="870" alt="Screenshot 2024-02-20 at 14 29 22" src="https://github.com/cloudflare/cloudflare-docs/assets/28503158/56aa8016-b3b6-4d64-8213-b1a26f16534a">
102+
103+
## GraphQL API Explorer
104+
105+
If you are adding a code snippet to the documentation that is an executable GraphQL query, you can add `graphql-api-explorer` right after `graphql` in the code block metadata (both must be present). This will render a button that allows users to open the query in the [GraphQL API Explorer](https://graphql.cloudflare.com/explorer). For example:
106+
107+
````
108+
```graphql graphql-api-explorer title="A GraphQL query"
109+
query GraphqlExample($zoneTag: string, $start: Time, $end: Time) {
110+
viewer {
111+
zones(filter: { zoneTag: $zoneTag }) {
112+
firewallEventsAdaptive(
113+
filter: { datetime_gt: $start, datetime_lt: $end }
114+
limit: 2
115+
orderBy: [datetime_DESC]
116+
) {
117+
action
118+
datetime
119+
host: clientRequestHTTPHost
120+
}
121+
}
122+
}
123+
}
124+
```
125+
````
126+
127+
When a user selects the `Run in GraphQL API Explorer` button, the following variables will be pre-populated in the GraphQL API Explorer along with the query.
128+
129+
:::note
130+
The user must be logged in or have an API token saved to see the query and variables pre-populated.
131+
:::
132+
133+
```
134+
{"zoneTag":"ZONE_ID", "start":"2025-05-07T14:54:36Z", "end":"2025-05-07T20:54:36Z"}
135+
```
136+
137+
### Conventions to auto populate `Variables` section in the GraphQL API Explorer
138+
139+
By default, the `Variables` section will be automatically populated based on the variables used in the GraphQL query.
140+
141+
- Any variable name that includes `start` and has a type of `Time` --> start: "2025-05-09T14:58:06Z" (6 hours from the current time)
142+
- e.g. `datetimeStart` also has `start` keyword, so it will be recognized for a start time (or date)
143+
- Any variable name that includes `end` and has a type of `Time` --> end: "2025-05-09T20:58:06Z" (current time)
144+
- Any variable name that includes `start` and has a type of `Date` --> start: "2025-05-07" (24 hours from the current date)
145+
- Any variable name that includes `end` and has a type of `Date` --> end: "2025-05-08" (current date)
146+
- `zoneTag` and has a type of `string` --> zoneTag: "ZONE_ID"
147+
- `accountTag` and has a type of `string` --> accountTag: "ACCOUNT_ID"
148+
- Any variable name that includes `id` and has a type of `string` --> id: "REPLACE_WITH_ID"
149+
- Any variable name and has a type of string --> anyString: "REPLACE_WITH_STRING"
150+
- `limit` with type `*int*` --> limit: 100
151+
152+
In addition to the variables that are automatically populated, you can add custom variables by setting their values as a JSON string in the `graphql-api-explorer` metadata.
153+
154+
````
155+
```graphql graphql-api-explorer='{"uID": "something"}' title="A GraphQL query"
156+
query GraphqlExample($zoneTag: string, $start: Time, $end: Time) {
157+
viewer {
158+
zones(filter: { zoneTag: $zoneTag }) {
159+
...
160+
}
161+
}
162+
}
163+
````
164+
165+
The variables added via the metadata value will be merged with the automatically populated variables.
166+
167+
```
168+
{"zoneTag":"ZONE_ID", "start":"2025-05-07T14:54:36Z", "end":"2025-05-07T20:54:36Z", "uId": "something"}
169+
```

ec.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import lightTheme from "solarflare-theme/themes/cloudflare-light-color-theme.jso
77
import pluginWorkersPlayground from "./src/plugins/expressive-code/workers-playground.js";
88
import pluginOutputFrame from "./src/plugins/expressive-code/output-frame.js";
99
import pluginDefaultTitles from "./src/plugins/expressive-code/default-titles.js";
10+
import pluginGraphqlApiExplorer from "./src/plugins/expressive-code/graphql-api-explorer.js";
1011

1112
import { pluginCollapsibleSections } from "@expressive-code/plugin-collapsible-sections";
1213

@@ -16,6 +17,7 @@ export default defineEcConfig({
1617
pluginOutputFrame(),
1718
pluginDefaultTitles(),
1819
pluginCollapsibleSections(),
20+
pluginGraphqlApiExplorer(),
1921
],
2022
themes: [darkTheme, lightTheme],
2123
styleOverrides: {

0 commit comments

Comments
 (0)