3

I have a custom query in my schema with its own pipeline resolver set up:

type Query {
    getMomentAppendView(mid: ID!): Moment
}

I am unsure what codegen labels it as in the Amplify framework. In the tutorials I only see how to get the pre-made queries for models. For example, on a simple @model (like Moment, above.)

Amplify.API.query(
    // Return a single item
    ModelQuery.get(Moment::class.java, mid),
    { resp ->
        val response = Response<Moment>()
        response.data = resp.data as Moment
        response.isSuccessful = true
        cont.resume(response)
    },
    { error ->
        val response = Response<Moment>()
        response.throwable = error
        response.isSuccessful = false
        cont.resume(response)
    }
)

How do I execute my custom GraphQL query?

Jameson
  • 6,400
  • 6
  • 32
  • 53
chrisdottel
  • 1,053
  • 1
  • 12
  • 21
  • The Amplify team is currently working on documentation for this use case. You can see some in-progress documentation here: https://github.com/aws-amplify/docs/pull/2141 In short, you can create your own `GraphQLRequest`, and pass that to `Amplfy.API.query(...)`, instead of using the `ModelQuery` utility. https://github.com/aws-amplify/amplify-android/blob/main/aws-api-appsync/src/main/java/com/amplifyframework/api/aws/AppSyncGraphQLRequest.java#L206 – Jameson Jul 31 '20 at 03:55

0 Answers0