Open redjonzaci opened 10 months ago
As an aside, the docs on making your own transformer/directive could be way better and more helpful.
This issue is related to adding multitenancy support to our app so I would really appreciate some help.
Another related question is:
Let's say I have a "GuardMutationFunction" that I want to insert (or link or reference) into the resolver pipeline of every model in the postAuth.2
slot. How would I do that outside a transformer/directive and without adding a Mutation.(Delete|Update){MODEL}.postAuth.2.req.vtl
resolver function for every model?
I know you have plenty on your plate, but following up.
Hi @redjonzaci, Apologies for the delay. I'll contact the engineering team to explore potential workarounds for you while we investigate reproducing the issue on our end.
@AnilMaktala it's okay and thanks!
Hey @AnilMaktala, any update from the team or any additional information we can provide?
We made it work by fitting https://www.npmjs.com/package/@aws-amplify/graphql-default-value-transformer to our need and updating the CLI to version 12.3.0. However, there are still some unclear things and the docs for adding a custom transformer need to be improved. If we will have any other question, will post here or in another issue if this is closed by then. Thank you!
Another question came up:
On mutation resolver pipelines, you do a query of the record in the auth
slot (which I don't know why is it used),
but that record isn't saved for subsequent slots to use it.
I need to use it in a postAuth
slot to check for attributes of a record.
Is there a way I can modify the auth
slot without overriding the auth
slots of every mutation
or without adding another slot that does querying (as we would do 2 queries for each mutation then)?
hey @redjonzaci - it looks like i am having similiar issues to you wrt creating custom transformers.
are you able to load your transformer into your project? if so, how do you do it? i am getting stuck on #2077
also, your multi-tenent transformer looks interesting. is this something you will release publically?
thanks
Hey @craig-at-metashield-io, how are you?
Or you could start an NPM package based on the defaultValue transformer and try to install that in your project.
thanks @redjonzaci - i'm doing well and i hope you are too 😄
i'll give that a try, but i must say that i've had a devil of time getting amplify stuff to build correctly. there's a lot of package conflicts.
hey @redjonzaci - thanks again for your helpful advice.
i have managed to get around the loading issue and finally have a working directive that validates string/number fields.
keep well,
@redjonzaci - Are you still having issues adding resolvers to custom slots? I understand that you have other questions on authoring custom transformers. I recommend to open a new issue for better visibility.
@sundersc I would appreciate if someone could answer the only question left: https://github.com/aws-amplify/amplify-category-api/issues/2019#issuecomment-1812505293.
Hi @sundersc,
Hi Amplify team, we've hit a bit of a snag with our current issue.
I'm wondering if anyone has any ideas on how we can better leverage the query that the @auth
directive is already executing. We're currently checking some attributes in the postAuth
slot, and there's also a need to compare the 'old' record with the 'new' one in the postUpdate
slot.
The challenge is, it seems like we're having to unnecessarily use an extra query or a resolver slot to re-query the data. At the moment, there doesn't appear to be a straightforward way to get the @auth
directive to either store the data in the stash or forward it down the chain via prev.results
.
Any thoughts or suggestions on this would be greatly appreciated! With the slot quota being hardset and immovable we are trying to be very conservative, also it feel really wasteful to waste the query.
Thanks, Dhimitri.
Hi @djorgji, we do not store the fetched item in stash and this might be something we need to take up as a feature request. I see the value in it especially for such customizations. Marking this as a feature request. For now, you might have to override the request template in Auth resolver slot that fetches the item to additionally also put it in a stash variable that you own.
Hi @phani-srikar, any suggestion on what the easiest way to do that across all resolvers? We are at 40 tables at the moment, and that is quite a few resolvers to override manually?
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
12.2.3
What operating system are you using?
Windows
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Describe the bug
This is the code in my custom transformer, but the contents of the request and response mapping templates don't make it either to disk or S3. (I have removed the contents of the mapping templates.)
In addition, there may be an issue below as it always evaluated to false when I tried it so my code ended up as an S3 location. https://github.com/aws-amplify/amplify-category-api/blob/02b9cc0308d591f9caa21729ce5236c4611c31b3/packages/amplify-graphql-transformer-core/src/appsync-function.ts#L62
But even when I fixed that, my custom transformer template code was nowhere to be found.
Expected behavior
The mapping templates in my custom transformer should make it to either S3 or disk.
Reproduction steps
The code in the "Describe the bug" section should suffice.
Project Identifier
No response
Log output
Additional information
No response
Before submitting, please confirm: