0

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, 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
}

Do I have to write custom resolvers? Is there a way to do this without custom resolvers? Thank you in advance

Subhendu Kundu
  • 3,618
  • 6
  • 26
  • 57
  • Hi did you already look at this tutorial? https://medium.com/@gerard.sans/finding-the-nearest-locations-around-you-using-aws-amplify-part-2-ce4603605be6 – Kevin Regenrek Apr 07 '20 at 15:33
  • Yes yes I did. It doesn't talk about how to use the `@key` to use with `geo_point`. So lets say I had to find all the events around 1km which are on open status, how would I do that? I have to end up writing a custom resolver? That means, I have no. use of the `@key` which I added :( Any idea how do I do that? – Subhendu Kundu Apr 07 '20 at 15:43

0 Answers0