1
votes

I have the following query:

query kitchen {
  getItemKitchen(id:"fakeIdHere") {
    id
    kitchenName
  }
}

which returns:

{
  "data": {
    "getItemKitchen": null
  }
}

And have defined the query in the schema as such:

type Query @aws_cognito_user_pools
@aws_api_key {
    getItemKitchen(id: ID!): ItemKitchen

The resolver req template is:

{
    "version":"2017-02-28",
    "operation":"GET",
    "path":"/myType/myIndex/_search",
    "params": {
        "body": {
            "query": {
                "match": {
                    "id.keyword": "${context.arguments.id}"
                }
            }
        }
    }
}

And my response template:

$util.toJson($context.result.get("_source"))

I expect the following response:

{
"result": {
        "_source": {
            "id": "HelloWorldTestId",
            "createdAt": "Hello, world!"
        }
    }
}

I also have a mutation which works fine, enabling me to create items on dynamodb which is then sent to elasticsearch for querying by a lambda function.

I've checked the item exists on elasticsearch.

Both my Elasticsearch and DynamoDb instances sit in a VPC. Before adding the VPC I was able to query the elasticsearch instance and get a response. According to the docs, this kind of response means there is no resolver attached, yet the mutations seem to work just fine. I've tried removing and re-attaching the resolvers, but nothing happens.

Any help would be much appreciated as this is becoming extremely frustrating.

1
What do you expect instead? an empty hash instead of null since you're querying a fake ID? - Val
I expect an item. The item in case exists. And that same query runs on kibana just fine, returning the expected item - hyprstack
returning only the $context argument changes nothing - hyprstack
Can you show the sample document you expect to match? - Val
Added the sample document - hyprstack

1 Answers

2
votes

Currently, AppSync does not support Elasticsearch instances that are behind a VPC. See the first line of the documentation here:

This is why the query was working for you prior to adding the VPC.