Open AdrKacz opened 2 weeks ago
After digging documentation, I realized best practice for my use case is simply to use ownerDefinedIn
when setting authorization, so I can work fine with client.graphql
and a custom field for ownership.
However, even though I'm not blocked anymore with this missing models
, the issue still remains. Why the models
are not populated on Lambda
? Are they supposed to only be used in the client?
+1
@AdrKacz at the moment, only client.graphql
is fully supported in lambdas. in order for client.models
to work, the model introspection schema has to be available in the configuration (Amplify.configure()
).
this requires some manual workarounds to ensure it's thee because of the way lambdas are bundled and deployed, they are not in sync with changes made to the amplify configuration on each deployment.
we have a page on accessing the graphql api from a lambda which also shows to use the graphql
client rather than the models
client for this reason:
we are working on making it easier to use the models
client in lambdas going forward. apologies for the inconvenience.
Environment information
Data packages
Description
I created a custom mutation is my models. This mutation can only be called by authenticated user and, among other things, create a
User
object defined in the models.In the Lambda handler I use
Amplify.configure
then generate the client withAmplify.generateClient<Schema>()
. However,client.models
isundefined
and so preventing me to callclients.models.User.get
orclients.models.User.create
.My client and backend look correctly configured, indeed, if I replace with a
graphql
operation, I canget
orcreate
, using:However, with this method, I can't specify an
owner
field, which is problematic. Usingclients.models.User.create
should resolve this issue by automatically populating theowner
field, but, as explained above, it is unfortunately not working.Thank you for your help.