docs/wiki/docusaurus-mdx-guide/graphiql-ide.mdx
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import GraphiQLIDE from '@site/src/components/GraphiQLIDE';
We use graphiql editor wherever applicable for example showcase throughout docs.
A GraphiQLIDE component is already created with the required custom logic. So, use GraphiQLIDE just like any other
React component.
Use it as follows:
import GraphiQLIDE from '@site/src/components/GraphiQLIDE';
<GraphiQLIDE
query={`query {
author_by_pk(id: 1) {
id
name
}
}`}
response={`{
"data": {
"author_by_pk": {
"id": 1,
"name": "Justin"
}
}
}`}
/>;
// highlight-start
import GraphiQLIDE from '@site/src/components/GraphiQLIDE';
<GraphiQLIDE
query={`query get_authors_in_pincode ($jsonFilter: jsonb){
// highlight-end
authors(
where: {
address: {_contains: $jsonFilter }
}
) {
id
name
address
}
}`}
// highlight-next-line
variables={`{
"jsonFilter": {
"pincode": 560095
}
}`}
// highlight-next-line
response={`{
"data": {
"authors": [
{
"id": 1,
"name": "Ash",
"address": {
"street_address": "161, 19th Main Road, Koramangala 6th Block",
"city": "Bengaluru",
"state": "Karnataka",
"pincode": 560095,
"phone": "9090909090",
}
}
]
}
}`}
/>;
Below is how it should look in UI.
<GraphiQLIDE
query={query get_authors_in_pincode ($jsonFilter: jsonb){ authors( where: { address: {_contains: $jsonFilter } } ) { id name address } }}
variables={{ "jsonFilter": { "pincode": 560095 } }}
response={{ "data": { "authors": [ { "id": 1, "name": "Ash", "address": { "street_address": "161, 19th Main Road, Koramangala 6th Block", "city": "Bengaluru", "state": "Karnataka", "pincode": 560095, "phone": "9090909090", } } ] } }}
/>