#Fetching model with O2M relationships in custom lambda-backed query

2 messages · Page 1 of 1 (latest)

delicate crest
#

Hi,

I'm trying to build a custom query backed by a lambda function that queries some data from dynamodb (my tables are defined by the datastore), applies some ad hoc filters to it then returns the result to my frontend.

I'm basically following these two doc pages:

Code for the query in the schema:

getCalendarEvents: a
      .query()
      .arguments({ from: a.datetime(), to: a.datetime() })
      .returns(a.ref(<Model_Name>).required().array())
      .authorization((allow) => [allow.authenticated()])
      .handler(a.handler.function(<function_name>)),

My issue: since <Model_Name> has a belongsTo field, typescript is mad that I'm returning the results of a list graphql operation. Is there a way to either populate this field in the list operation graphql schema generated by npx ampx generate graphql-client-code or only select some fields when writing .returns(a.ref(<Model_Name>).required().array())?

delicate crest
#

Bumping this up 🙂
I also think this could be solved by having the full client implementation working in lambda, is there an ETA on it? See #1263058936320229476 message