-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Labels
GraphQL APIIssues related to the API (GraphQL) CategoryIssues related to the API (GraphQL) CategorybugSomething is not working; the issue has reproducible steps and has been reproducedSomething is not working; the issue has reproducible steps and has been reproduced
Description
Environment information
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M4
Memory: 174.03 MB / 16.00 GB
Shell: /bin/zsh
Binaries:
Node: 20.19.3 - ~/.nvm/versions/node/v20.19.3/bin/node
Yarn: undefined - undefined
npm: 10.8.2 - ~/.nvm/versions/node/v20.19.3/bin/npm
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/auth-construct: 1.8.1
@aws-amplify/backend: 1.16.1
@aws-amplify/backend-ai: Not Found
@aws-amplify/backend-auth: 1.7.1
@aws-amplify/backend-cli: 1.8.0
@aws-amplify/backend-data: 1.6.1
@aws-amplify/backend-deployer: 2.1.3
@aws-amplify/backend-function: 1.14.1
@aws-amplify/backend-output-schemas: 1.7.0
@aws-amplify/backend-output-storage: 1.3.1
@aws-amplify/backend-secret: 1.4.0
@aws-amplify/backend-storage: 1.4.1
@aws-amplify/cli-core: 2.2.1
@aws-amplify/client-config: 1.8.0
@aws-amplify/data-construct: 1.16.3
@aws-amplify/data-schema: 1.21.1
@aws-amplify/deployed-backend-client: 1.8.0
@aws-amplify/form-generator: 1.2.4
@aws-amplify/model-generator: 1.2.0
@aws-amplify/platform-core: 1.10.0
@aws-amplify/plugin-types: 1.11.0
@aws-amplify/sandbox: 2.1.2
@aws-amplify/schema-generator: 1.4.0
@aws-cdk/toolkit-lib: 1.1.1
aws-amplify: 6.15.5
aws-cdk-lib: 2.204.0
typescript: 5.9.2
npm warn exec The following package was not found and will be installed: [email protected]
No AWS environment variables
No CDK environment variables
Describe the bug
- When using Amplify's ModelQueries.get() in a Flutter application with a schema that includes a TemporalDateTime field, the query fails with a JsonUnsupportedObjectError. This occurs when attempting to serialize a TemporalDateTime object for a GraphQL request.
[+] Error: JsonUnsupportedObjectError (Converting object to an encodable object failed: Instance of 'TemporalDateTime')
-
This issue creates a conflict between the schema definition, which uses TemporalDateTime, and the actual query execution, which cannot serialize these objects. It's particularly problematic because the TemporalDateTime type is provided by the Amplify library itself, suggesting it should be fully supported.
-
A workaround involves replacing TemporalDateTime with standard Dart DateTime objects and creating a custom model identifier, but this shouldn't be necessary given that TemporalDateTime is a supported type in the schema.
Reproduction steps
- Create a Flutter application using Amplify CLI Gen2 with the following schema:
Metrics: a
.model({
hwid: a.string().required(),
sessionStart: a.datetime().required(),
// other fields...
})
.identifier(["hwid", "sessionStart"])
.secondaryIndexes((index) => [index("sessionStart").queryField("listByDate")])
.authorization((allow) => [allow.authenticated()])
- Generate the models using Amplify CLI.
- Attempt to query the data using ModelQueries.get():
final hwid = "94B216FCC67F";
final dateKey = "2025-03-28T23:07:34.000Z";
final request = ModelQueries.get(
Metrics.classType,
Metrics(hwid: hwid, sessionStart: TemporalDateTime.fromString(dateKey))
.modelIdentifier,
);
final response = await Amplify.API.query(request: request).response;
- Run the query. It will fail with the JsonUnsupportedObjectError mentioned above.
Metadata
Metadata
Assignees
Labels
GraphQL APIIssues related to the API (GraphQL) CategoryIssues related to the API (GraphQL) CategorybugSomething is not working; the issue has reproducible steps and has been reproducedSomething is not working; the issue has reproducible steps and has been reproduced