How can I create a hook, so that during an insert,...
# prisma-whats-new
How can I create a hook, so that during an insert, for example, a bunch of other items are initialized. For example, a user is created, so after it s crested, create a new "Organization" a new "Profile", etc. Can that be done with the functions hooks?
That can definitely be done. Lemme find a good example...
This is a messy example, but it's straight from the graphcool templates:
basically, within a hook, you grab an API you can send queries and mutations to, like this:
Copy code
const graphcool = fromEvent(event)
const api = graphcool.api('simple/v1')
then you send a mutation to it with
api.request(graphQLString, variables)
so you could just write one huge mutation that adds an Organization and Profile and whatever else, and send that to the API under an
hook on
operation: User.create
So antthing done through the api.request bypasses the permissions and executed as Admin?
Also, in order to do this, I'd have to use the Graphcool framework and can't be done just in graphcool cloud?