We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
npm
Not applicable
7.6.23
macOS
No
api
When @belongsTo is used with implicit fields to reference a foreign composite key, queries do not work as expected. See the reproduction steps.
@belongsTo
@belongsTo works properly with foreign composite keys.
Owner
mutation MyMutation { createOwner(input: {id: "1", name: "Foo", wea: "FooWea"}) { blogs { items { id } } createdAt id name updatedAt wea } }
name
wea
mutation MyMutation { createOwner(input: {id: "1", name: "Foo", wea: "FooWea2"}) { blogs { items { id } } createdAt id name updatedAt wea } }
Blog
mutation MyMutation { createBlog(input: {id: "1", name: "FooBlog", ownerBlogsId: "Foo"}) { updatedAt ownerBlogsId owner { createdAt id name updatedAt wea } name id createdAt } }
The Blog item is successfully created, but the @belongsTo does not properly identify the correct Owner object, so the following error is returned:
{ "data": { "createBlog": null }, "errors": [ { "path": [ "createBlog", "owner" ], "locations": null, "message": "Cannot return null for non-nullable type: 'Owner' within parent 'Blog' (/createBlog/owner)" } ] }
Similarly, any attempt to query for a Blog with the Owner in the selection set returns the same error for the same reason.
The Blog.owner.req.vtl file is relevant. Note the presence of $ctx.source.undefined:
Blog.owner.req.vtl
$ctx.source.undefined
#if( $ctx.source.deniedField ) #return($util.toJson(null)) #end #if( $util.isNull($ctx.source.ownerBlogsId) ) #return #else #set( $GetRequest = { "version": "2018-05-29", "operation": "Query" } ) $util.qr($GetRequest.put("query", { "expression": "#partitionKey = :partitionValue AND #sortKeyName = :sortKeyName", "expressionNames": { "#partitionKey": "name", "#sortKeyName": "wea" }, "expressionValues": { ":partitionValue": $util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.ownerBlogsId, "___xamznone____"))), ":sortKeyName": $util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.undefined, "___xamznone____"))) } })) #if( !$util.isNullOrEmpty($ctx.stash.authFilter) ) $util.qr($GetRequest.put("filter", $util.parseJson($util.transform.toDynamoDBFilterExpression($ctx.stash.authFilter)))) #end $util.toJson($GetRequest) #end
input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY! type Blog @model { id: ID! name: String! owner: Owner! @belongsTo } type Owner @model { id: ID! name: String! @primaryKey(sortKeyFields: ["wea"]) wea: String! blogs: [Blog] @hasMany }
No response
The text was updated successfully, but these errors were encountered:
pavellazar
Successfully merging a pull request may close this issue.
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
Not applicable
Amplify CLI Version
7.6.23
What operating system are you using?
macOS
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No
Amplify Categories
api
Amplify Commands
Not applicable
Describe the bug
When
@belongsTo
is used with implicit fields to reference a foreign composite key, queries do not work as expected. See the reproduction steps.Expected behavior
@belongsTo
works properly with foreign composite keys.Reproduction steps
Owner
:Owner
with the samename
, but differentwea
value:Blog
:The
Blog
item is successfully created, but the@belongsTo
does not properly identify the correctOwner
object, so the following error is returned:Similarly, any attempt to query for a
Blog
with theOwner
in the selection set returns the same error for the same reason.The
Blog.owner.req.vtl
file is relevant. Note the presence of$ctx.source.undefined
:GraphQL schema(s)
Log output
Not applicable
Additional information
No response
The text was updated successfully, but these errors were encountered: