Skip to content
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

ModelQueriesFactory.get only uses ID, impossible to fetch the entity with a pair of hashKey & rangeKey #1710

Closed
1 of 9 tasks
Simon-PumpAndUp opened this issue Jun 11, 2022 · 3 comments
Labels
duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category

Comments

@Simon-PumpAndUp
Copy link

Simon-PumpAndUp commented Jun 11, 2022

Description

Hello,

I have the following model:
hashKey: Int! @primaryKey(sortKeyFields: ["rangeKey"])

I want to fetch one entity from this model so I went for:

final request = ModelQueries.get(Party.classType, ID);
final response = await Amplify.API.query(request: request).response;

ModelQueries.get only accepts an ID and I have entities sharing hashKeys. (reponse.data is not a list, not sure what happens if I use one of the hashKey as ID, I didn't try.)

Also, ModelQueries.get's ID is expecting a string whereas here my hashKey is an int.

The generated model contains both keys:
getParty(hashKey: Int!, rangeKey: String!)...

I should be able to bypass this by creating my own query but wanted to check with you before.

Thanks!

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Storage

Steps to Reproduce

No response

Screenshots

No response

Platforms

  • iOS
  • Android

Android Device/Emulator API Level

No response

Environment

N/A

Dependencies

N/A

Device

N/A

OS

N/A

CLI Version

8.4.0

Additional Context

No response

@Simon-PumpAndUp
Copy link
Author

Hi,

Would it be possible to have feedback on this please?

@dnys1
Copy link
Contributor

dnys1 commented Jun 16, 2022

Hi @Simon-PumpAndUp - so sorry for the delay in response. We are currently looking into adding custom primary key support which will enable using model helpers with compound keys. Please follow this feature ticket for updates: #1426. I don't have a hard estimate on delivery, but we're actively working on bringing support ASAP!

@dnys1 dnys1 closed this as completed Jun 16, 2022
@dnys1 dnys1 added duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category labels Jun 16, 2022
@Simon-PumpAndUp
Copy link
Author

Simon-PumpAndUp commented Jun 17, 2022

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category
Projects
None yet
Development

No branches or pull requests

2 participants