You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/graphql.md
+58-44Lines changed: 58 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,49 +127,6 @@ For example, to query a book having as identifier `89`, you have to run the foll
127
127
128
128
Note that in this example, we're retrieving two fields: `title`and `isbn`.
129
129
130
-
### Pagination
131
-
132
-
API Platform natively enables a cursor-based pagination for collections.
133
-
It supports [GraphQL's Complete Connection Model](https://graphql.org/learn/pagination/#complete-connection-model) and is compatible with [Relay's Cursor Connections Specification](https://facebook.github.io/relay/graphql/connections.htm).
134
-
135
-
Here is an example query leveraging the pagination system:
136
-
137
-
```graphql
138
-
{
139
-
offers(first: 10, after: "cursor") {
140
-
totalCount
141
-
pageInfo {
142
-
endCursor
143
-
hasNextPage
144
-
}
145
-
edges {
146
-
cursor
147
-
node {
148
-
id
149
-
}
150
-
}
151
-
}
152
-
}
153
-
```
154
-
155
-
The two parameters `first` and `after` are necessary to make the paginated query work, more precisely:
156
-
157
-
* `first` corresponds to the items per page starting from the beginning;
158
-
* `after` corresponds to the `cursor` from which the items are returned.
159
-
160
-
The current page always has an `endCursor` present in the `pageInfo` field.
161
-
To get the next page, you would add the `endCursor` from the current page as the `after` parameter.
162
-
163
-
```graphql
164
-
{
165
-
offers(first: 10, after: "endCursor") {
166
-
}
167
-
}
168
-
```
169
-
170
-
When the property `hasNextPage` of the `pageInfo` field is false, you've reached the last page.
171
-
If you move forward, you'll end up having an empty result.
172
-
173
130
### Custom Queries
174
131
175
132
To create a custom query, first of all you need to create its resolver.
@@ -343,7 +300,7 @@ You custom queries will be available like this:
343
300
}
344
301
```
345
302
346
-
# Mutations
303
+
## Mutations
347
304
348
305
If you don't know what mutations are yet, the documentation about them is [here](https://graphql.org/learn/queries/#mutations).
349
306
@@ -728,6 +685,8 @@ For example, if you want to search the offers with a green or a red product you
728
685
API Platform natively enables a cursor-based pagination for collections.
729
686
It supports [GraphQL's Complete Connection Model](https://graphql.org/learn/pagination/#complete-connection-model) and is compatible with [Relay's Cursor Connections Specification](https://facebook.github.io/relay/graphql/connections.htm).
730
687
688
+
### Using the Cursor-based Pagination
689
+
731
690
Here is an example query leveraging the pagination system:
732
691
733
692
```graphql
@@ -784,6 +743,61 @@ For the previous page, you would add the `startCursor` from the current page as
784
743
How do you know when you have reached the last page? It is the aim of the property `hasNextPage` or `hasPreviousPage` in `pageInfo`.
785
744
When it is false, you know it is the last page and moving forward or backward will give you an empty result.
786
745
746
+
### Disabling the Pagination
747
+
748
+
See also the [pagination documentation](pagination.md#disabling-the-pagination).
749
+
750
+
### Globally
751
+
752
+
The pagination can be disabled for all GraphQL resources using this configuration:
753
+
754
+
```yaml
755
+
# api/config/packages/api_platform.yaml
756
+
api_platform:
757
+
graphql:
758
+
collection:
759
+
pagination:
760
+
enabled: false
761
+
```
762
+
763
+
### For a Specific Resource
764
+
765
+
It can also be disabled for a specific resource (REST and GraphQL):
0 commit comments