Logo-amall

Create DB entry as admin after user action

Last active 15 days ago

14 replies

1 views

  • SI

    I want to insert a row into a table that no user should have write access. What is the way to do this in this setup?

  • DA

    that is the default mode with hasura. Only admin can mutate/query data unless you specify extra permissions via roles

  • SI

    but how can I create a mutation after something has happened on the frontend?

  • SI

    since I dont want to execute it in the context of the logged in user

  • DA

    you could send the request to a serverless function instead and have it trigger the mutation for you. Why are you trying to do a mutation as an admin on behalf of user?

  • SI

    I want to create some subscriptions

  • SI

    but I dont want the user to create it

  • SI

    but it should happen after payment

  • DA

    ok, that makes sense. My suggestion would be to use a lambda function for that then. You can even connect a lambda function as a remote schema. So the user would call the lambda function and the lambda function would then implement the business logic you need and act as admin

  • SI

    is there documentation regarding this?

  • DA

    not for this particular use case but we have an example on how to do something similar, it might actually what you need in this case

  • DA

    https://nhost.io/blog/nextjs-stripe-starter-template

  • DA

    that solution uses the trick I was explaining:

    https://github.com/nhost/nextjs-stripe-starter

  • SI

    awesome. thank you.will check it out

Last active 15 days ago

14 replies

1 views