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

How to combine key with custom resolvers with amplify or appsync graphql queries? #3888

Closed
subhendukundu opened this issue Apr 7, 2020 · 8 comments
Assignees
Labels
graphql-transformer-v1 Issue related to GraphQL Transformer v1 question General question

Comments

@subhendukundu
Copy link

Which Category is your question related to?
GraphQl query

Amplify CLI Version
4.17.2
I am using amplify graphql APIs. I have added a few @key for my search and sort of the events data. Then I have added a custom Query to search nearby events by lat and long. Now if had to search the nearby events by creatorId or status with location with a limit, how do I do it?

type Event @model
  @key(name: "byOwnerUser", fields: ["creatorId"])
  @searchable
{
  id:  ID!
  name: String!
  location: Location
  date: AWSDate!
  creatorId: ID!
  status: Boolean
  createdAt: AWSTimestamp
  updatedAt: AWSTimestamp
  users: [UserEvents] @connection(name: "EventsUser")
}

type Location {
  lat: Float!
  lon: Float!
}

input LocationInput {
  lat: Float
  lon: Float
}

type Query {
  nearbyEvents(location: LocationInput!, km: Int): EventConnection
}

I am stuck with this for a while now. Do I have to write custom resolvers? Is there a way to do this without custom resolvers?
Thank you in advance

@SwaySway
Copy link
Contributor

SwaySway commented Apr 7, 2020

Hello @subhendukundu if you are referring to how to do a geo search this is currently being tracked as a feature request, There are a few workaround implementations discussed in this thread as well aws-amplify/amplify-category-api#444

@SwaySway SwaySway added graphql-transformer-v1 Issue related to GraphQL Transformer v1 question General question labels Apr 7, 2020
@subhendukundu
Copy link
Author

subhendukundu commented Apr 7, 2020

Well yes I am aware of that. I am following https://medium.com/@tobinc/aws-amplify-graphql-with-geo-point-and-custom-resources-free-elasticsearch-provider-d1742fbc4ceb for enabling the geo search for now which is working great. Sorry if my question didn't make much sense but let me put it this way. If I had to use these workarounds and also add few more @key with it, will that be possible?
In other words from my event table if I had to search a list of events by Geo location with status and creatorId, how would I do that? Give me a lead?

@SwaySway
Copy link
Contributor

SwaySway commented Apr 8, 2020

Are you trying to see if adding @key would need a different implementation than what is listed in the article? If so @key shouldn't affect this since it pertains more to how you query your DynamoDB table. In this case you are looking at changing the query to your elasticsearch cluster to include creatorID and Status. This would involve adding those parameters as fields in the input type and editing the request resolver to include them in the filter.

@subhendukundu
Copy link
Author

Thank you so much for explaining that.
Is there any reference where I can get some idea of how to add elastic search cluster to include creatorID and Status? Any tutorial or docs or example will be great.

@stale
Copy link

stale bot commented May 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented May 20, 2020

This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.

@stale stale bot closed this as completed May 20, 2020
@Jmales
Copy link

Jmales commented Jun 7, 2020

I'm having the same doubt.

I have and entity and was trying to use @key instead of @connection (due to #1656).

But now I have a non-scalar in my entity and the filters are not generated automatically for that non-scalar "Location".

Is there any example where this is implemented in such way? The documentation is really bad at the moment

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
graphql-transformer-v1 Issue related to GraphQL Transformer v1 question General question
Projects
None yet
Development

No branches or pull requests

3 participants