Is it possible to use a returned value from the fi...
# prisma-whats-new
a
Is it possible to use a returned value from the first query in a mutation call, and use it as a variable in the second query?
Copy code
createUser(
      authProvider: {
        email: {
          email: $email,
          password: $password
        }
      }
    ) {
      id // this should be used as $userId in 'createHandler'
    }

    createHandler(
      firstName: $firstName,
      lastName: $lastName,
      email: $email,
      userId: $userId // <-- this one
    ) {
      id
    }
a
However, in this specific case you could create a Schema Extension mutation, which does both, and returns the handlerId
👍 1
d
You could also use a nested create mutation in this use case: https://www.graph.cool/docs/reference/simple-api/nested-create-mutations-vaet3eengo/
Something like:
createUser( authProvider: { email: { email: $email, password: $password } handlers: [{ firstName: $firstName, lastName: $lastName, email: $email }] } ) { id }
👍🏻 2
(assuming the user-handler relationship is 1-n)
This will create a Handler and connect it to the user that is being created
a
@dankent this looks like the solution i am looking for. Thanks !
It's a 1-1 relationship, but this also seems to work:
Copy code
createUser(
    authProvider: {
      email: {
        email: $email,
        password: $password
      }
    }
    handler: {
      firstName: $firstName,
      lastName: $lastName,
      email: $email
    }
  ) {
    id
  }
👍🏻 1