Add syntax coloration

Baptiste Darthenay 2020-07-31 11:14:24 +02:00
parent 8af66e5680
commit 2511ba50bb

@ -4,7 +4,7 @@ For this example, we're going to assume a basic understanding of how [Relay pagi
In a nutshell, `pagination` is implemented via graphene relay's `Connection` and `ConnectionField` pairing. With these in place, you'll see `pageInfo` available within your queries. It looks something like this: In a nutshell, `pagination` is implemented via graphene relay's `Connection` and `ConnectionField` pairing. With these in place, you'll see `pageInfo` available within your queries. It looks something like this:
``` ```json
"pageInfo": { "pageInfo": {
"startCursor": "YXJyYXljb25uZWN0aW9uOjQx", "startCursor": "YXJyYXljb25uZWN0aW9uOjQx",
"endCursor": "YXJyYXljb25uZWN0aW9uOjQz", "endCursor": "YXJyYXljb25uZWN0aW9uOjQz",
@ -14,18 +14,18 @@ In a nutshell, `pagination` is implemented via graphene relay's `Connection` and
``` ```
In addition to a `cursor` element within `edges` that will show you the cursor id for each element, like so: In addition to a `cursor` element within `edges` that will show you the cursor id for each element, like so:
``` ```graphql
edges { edges {
cursor cursor
node { node {
<whatever> <whatever>
} }
} }
``` ```
The basic schema below provides relay cursor-based pagination, combined with graphene_django filter capability. The basic schema below provides relay cursor-based pagination, combined with graphene_django filter capability.
``` ```py
from graphene import relay from graphene import relay
from graphene_django.types import DjangoObjectType from graphene_django.types import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField from graphene_django.filter import DjangoFilterConnectionField
@ -44,7 +44,7 @@ class Query(object):
``` ```
The following query, (the pageInfo element is included for illustration, but isn't necessary for the query to resolve): The following query, (the pageInfo element is included for illustration, but isn't necessary for the query to resolve):
``` ```graphql
{ {
places(first: 3, after: "YXJyYXljb25uZWN0aW9uOjQx") { places(first: 3, after: "YXJyYXljb25uZWN0aW9uOjQx") {
pageInfo { pageInfo {
@ -65,7 +65,7 @@ The following query, (the pageInfo element is included for illustration, but isn
``` ```
Gives us: Gives us:
``` ```json
{ {
"data": { "data": {
"places": { "places": {