-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PaginatedResult<T>.requestForNextResult does not use the authorizationMode from the previous query. #4585
Comments
I suspect the issue comes from this line:
if (modelType is PaginatedModelType) {
final filter = request.variables['filter'] as Map<String, dynamic>?;
final limit = request.variables['limit'] as int?;
final resultNextToken = dataJson![_nextToken] as String?;
dynamic requestForNextResult;
// If result has nextToken property, prepare a request for the next page of results.
if (resultNextToken != null) {
final variablesWithNextToken = <String, dynamic>{
...request.variables,
_nextToken: resultNextToken,
};
requestForNextResult = GraphQLRequest<T>( // <<=================== here (line 97)
document: request.document,
decodePath: request.decodePath,
variables: variablesWithNextToken,
modelType: request.modelType,
);
}
decodedData = modelType.fromJson(
dataJson!,
limit: limit,
filter: filter,
requestForNextResult:
requestForNextResult as GraphQLRequest<PaginatedResult<Model>>?,
) as T;
} else {
decodedData = modelType.fromJson(dataJson!) as T;
}
return GraphQLResponse<T>(data: decodedData, errors: errors);
It omits copying over the authorizationMode from the previous request. |
A workaround to the problem is to copy the final nextRequest = result.data?.requestForNextResult?.copyWith(
authorizationMode: APIAuthorizationType.oidc,
);
Sidenote: Currently, |
Hi @naedx, thank you for submitting this issue. We'll take a look at it and get back to you when there is an update. |
A fix for this was merged an should be included in the next release |
Awesome, thank you! Looking forward to it. |
Thank you for your patience. The issue has been fixed in version 1.8.0. and I'm closing it. However, if you encounter any issues after updating to version 1.8.0, please don't hesitate to reopen it. |
Description
PaginatedResult<T>.requestForNextResult
does not use theauthorizationMode
from the query that it follows.This manifests when the first query overrides the authorizationMode by using a custom OIDC Provider to provide the ID Token instead of the Access Token. The subsequent queries using
PaginatedResult<T>.requestForNextResult
defaults back to the the cognito access token, causing the query to fail.Categories
Steps to Reproduce
Execute the first request
Execute the second request using
.requestForNextResult
from the previous query:Screenshots
No response
Platforms
Flutter Version
3.19.0
Amplify Flutter Version
1.7.0
Deployment Method
Amplify CLI
Schema
The text was updated successfully, but these errors were encountered: