question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@key on field annotated with @connection

See original GitHub issue

** Which Category is your question related to? ** GraphQL Schema

** What AWS Services are you utilizing? ** API, AppSync

** Provide additional details e.g. code snippets **

The below produces this expected error on amplify push: Expected scalar and got User

type Membership @model @key(fields: ["user"], name: "ByUser", queryField: "membershipsByUser") {
  id: ID! 
  channel: Channel @connection(name: "channelMemberships")
  user: User @connection(name: "userMemberships")
}

Can we create a gsi on a connection field? Ultimately it’s represented by the id.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
rawadrifaicommented, Oct 8, 2019

oh wow sorry guys just saw this @davidbiller @amirmishani If I remember correctly I wanted to be able to query the table with the non key field which was a @connection field. No point to create a gsi around, since @connection I believe creates a gsi under the hood. So You really just need to go to the table being referenced. In my case for example, table User has memberships and if I say user.memberships, that will give me all the user memberships I need. That’s technically a query using a gsi in the membership table.

So long story short, don’t use a @key on @connection.

1reaction
davidbillercommented, Jul 9, 2019

I realized I’m approaching this the wrong way. Too much friction. Please ignore. If anyone comes across a similar requirement, hit me up.

Here 😃 so how did you fix this? i need to use @key, but than i need a connection for a field inside

Read more comments on GitHub >

github_iconTop Results From Across the Web

Key annotations you need to know when working with JPA ...
JPA and Hibernate require you to specify at least one primary key attribute for each entity. You can do that by annotating an...
Read more >
java - How can I mark a foreign key constraint using Hibernate ...
I am trying to use Hibernate annotation for writing ...
Read more >
Code First Data Annotations - EF6 | Microsoft Learn
Code First Data Annotations in Entity Framework 6. ... This property will map to a primary key column in the database.
Read more >
The Key Attribute - Learn Entity Framework Core
The Key attribute is used to denote the property that uniquely identifies an entity (the EntityKey ), and which is mapped to the...
Read more >
Defining data using Room entities - Android Developers
You define each Room entity as a class that is annotated with @Entity . A Room entity includes fields for each column in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found