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
When my resolver returns null due to the absence of data, AWS AppSync correctly sets the root query result to null. However, the errors array includes validation errors for missing non-nullable fields within the type, despite the entire query result being null. This behavior seems inconsistent, as no subfields should be validated when the root query result is null.
Expected Behavior:
If the resolver returns null for the root type, AppSync should:
• Return null for the query result.
• Exclude validation errors for non-nullable subfields, as they are irrelevant when the root type is null.
Observed Behavior:
• The query result is correctly null.
• The errors array contains messages about missing non-nullable subfields, even though the root type is null.
Reproduce instruction
# Types
type User {
id: ID!
firstName: String!
}
type Query {
getUser(id: ID!): User
}
Resolver:
import { util } from "@aws-appsync/utils";
import { select, createPgStatement, toJsonObject } from "@aws-appsync/utils/rds";
function request(ctx) {
const { id } = ctx.args;
const where = {
id: {
eq: id
}
};
const statement = select({
table: "users",
columns: "*",
where,
limit: 1
});
return createPgStatement(statement);
}
function response(ctx) {
const { error, result } = ctx;
if (error) {
return util.appendError(
error.message,
error.type,
result
);
}
return toJsonObject(result)[0][0];
}
export {
request,
response
};
Query an non existing user id through app sync console:
query GetUser {
getUser(id: "1") {
firstName
id
}
}
Issue Description:
When my resolver returns null due to the absence of data, AWS AppSync correctly sets the root query result to null. However, the errors array includes validation errors for missing non-nullable fields within the type, despite the entire query result being null. This behavior seems inconsistent, as no subfields should be validated when the root query result is null.
Expected Behavior:
If the resolver returns null for the root type, AppSync should:
• Return null for the query result.
• Exclude validation errors for non-nullable subfields, as they are irrelevant when the root type is null.
Observed Behavior:
• The query result is correctly null.
• The errors array contains messages about missing non-nullable subfields, even though the root type is null.
Reproduce instruction
Resolver:
Query an non existing user id through app sync console:
Response:
The text was updated successfully, but these errors were encountered: