I am evaluating the Cosmos DB data source for a GraphQL API in Azure API Management.
To perform pagination evaluation, I'm trying to add a paging
section to the resolver, but I'm unsure how to retrieve the value of continuation-token
from the request.
Here is my configuration (attempting to retrieve from the continuationToken
argument):
Schema
type Query {
getUsers(continuationToken: String): UsersResult!
}
type User {
id: ID!
name: String!
age: Int!
}
type UsersResult {
items: [User!]!
hasNextPage: Boolean!
endCursor: String
}
Resolver
<cosmosdb-data-source>
<connection-info>
<connection-string use-managed-identity="true">
AccountEndpoint=https://my-cosmos-db-name.documents.azure.com:443/;
</connection-string>
<database-name>demo-db</database-name>
<container-name>users</container-name>
</connection-info>
<query-request>
<sql-statement>
SELECT * FROM c
</sql-statement>
<paging>
<max-item-count>2</max-item-count>
<continuation-token>
@(context.GraphQL.Arguments["continuationToken"])
</continuation-token>
</paging>
</query-request>
</cosmosdb-data-source>
When I execute the evaluation with the above configuration, I receive the following response. Is there an error in the specified method?
{
"statusCode": 400,
"message": "Resolvers are not defined and a service URL is not configured",
"activityId": "5e3272d6-1741-4ac8-9fa1-718709c87920"
}
By the way, it worked correctly when I specified a fixed value like this:
<continuation-token>
W3sidG9rZW4iOiItUklEOn5aejhHQU5aQzI0c0NBQUFBQUFBQUFBPT0jUlQ6MSNUUkM6MiNJU1Y6MiNJRU86NjU1NjcjUUNGOjgiLCJyYW5nZSI6eyJtaW4iOiIiLCJtYXgiOiJGRiJ9fV0=
</continuation-token>
Also, the documentation states that the continuation-token
property can have a template
attribute.
https://learn.microsoft.com/en-gb/azure/api-management/cosmosdb-data-source-policy
<paging>
<max-item-count template="liquid" >
Maximum number of items returned by the query
</max-item-count>
<continuation-token template="liquid">
Continuation token for paging
</continuation-token>
</paging>
However, when I actually specify the template
attribute, I receive the following error message and cannot save it:
Error in element 'cosmosdb-data-source' on line 1, column 2: The 'template' attribute is not declared.
- resource
- sku: Consumption, Development
- location: Japan East