aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

APPsync function with OPENSEARCH

Open purushottam858 opened this issue 3 years ago • 1 comments

I have a function which should query opensearch and return results . but it is always returning the below error .

this function is only function in pipeline resolver which is attached to "getPostApp" query in below schema . In below images you can see the templates of function . I guess there is something wrong with templates , I am not sure which one .

query hh{ getPostApp(title: "hh") { id title content author } }

============error======================

{ "data": { "getPostApp": null }, "errors": [ { "path": [ "getPostApp", "id" ], "locations": null, "message": "Cannot return null for non-nullable type: 'ID' within parent 'PostApp' (/getPostApp/id)" }, { "path": [ "getPostApp", "title" ], "locations": null, "message": "Cannot return null for non-nullable type: 'String' within parent 'PostApp' (/getPostApp/title)" }, { "path": [ "getPostApp", "content" ], "locations": null, "message": "Cannot return null for non-nullable type: 'String' within parent 'PostApp' (/getPostApp/content)" } ] }

================ schema ===================

input CreatePostAppInput { title: String! content: String! author: String }

input DeletePostAppInput { id: ID! }

type Mutation { createPostApp(input: CreatePostAppInput!): PostApp updatePostApp(input: UpdatePostAppInput!): PostApp deletePostApp(input: DeletePostAppInput!): PostApp }

type PostApp { id: ID! title: String! content: String! author: String }

type PostAppConnection { items: [PostApp] nextToken: String }

type Query { getPostApp(title: String!): PostApp listPostApps(filter: TablePostAppFilterInput, limit: Int, nextToken: String): PostAppConnection }

type Subscription { onCreatePostApp( id: ID, title: String, content: String, author: String ): PostApp @aws_subscribe(mutations: ["createPostApp"]) onUpdatePostApp( id: ID, title: String, content: String, author: String ): PostApp @aws_subscribe(mutations: ["updatePostApp"]) onDeletePostApp( id: ID, title: String, content: String, author: String ): PostApp @aws_subscribe(mutations: ["deletePostApp"]) }

input TableBooleanFilterInput { ne: Boolean eq: Boolean }

input TableFloatFilterInput { ne: Float eq: Float le: Float lt: Float ge: Float gt: Float contains: Float notContains: Float between: [Float] }

input TableIDFilterInput { ne: ID eq: ID le: ID lt: ID ge: ID gt: ID contains: ID notContains: ID between: [ID] beginsWith: ID }

input TableIntFilterInput { ne: Int eq: Int le: Int lt: Int ge: Int gt: Int contains: Int notContains: Int between: [Int] }

input TablePostAppFilterInput { id: TableIDFilterInput title: TableStringFilterInput content: TableStringFilterInput author: TableStringFilterInput }

input TableStringFilterInput { ne: String eq: String le: String lt: String ge: String gt: String contains: String notContains: String between: [String] beginsWith: String }

input UpdatePostAppInput { id: ID! title: String content: String author: String }

============== WhatsApp Image 2021-12-16 at 6 36 26 PM WhatsApp Image 2021-12-16 at 6 36 26 PM (1) WhatsApp Image 2021-12-16 at 6 36 26 PM (2) WhatsApp Image 2021-12-16 at 6 36 26 PM (3) WhatsApp Image 2021-12-16 at 6 36 26 PM (4)

purushottam858 avatar Dec 16 '21 13:12 purushottam858

looks like the issue is that your main type expects the following fields:

id: ID! title: String! content: String!

the ! at the end of the type means that these fields are required. it seems that the response from opensearch and the way you are mapping the data does not include these fields. since the fields are required, appsync returns an error.

onlybakam avatar Feb 07 '22 23:02 onlybakam