0

I want to alter the mutation using Laravel Creating event. I want to fetch task ID from key that is coming from front end. And then i want to add this ID in replace of key so that my task will be create automatically using lighthouse structure. Here is sample mutation

mutation
{
  createUser(input: {
    firstname: "last"
    email: "abc@gmaiol.com"
    task:
    {
      create: { 
         key: 'reminder'
      }
    }
  })
  {
    id
  }
}

1 Answers1

0

My recommendation is to create a resolver for your specific situation:

mutation
{
  createUser(input: {firstname: "last", email: "abc@gmaiol.com", key: "reminder"})
  {
    id
  }
}

Remember to always use double quotes " ", never use single quotes ' '

In your schema.graphql

input newUser {
    firstname: String!
    email: String!
    key: String!
}

type newUserResponse {
    ID: ID!
}

createUser(data: newUser): newUserResponse @field(resolver: "App\\GraphQL\\Mutations\\createUser")

Here's an example of the resolver: Resolver example

Also check the docs: https://lighthouse-php.com/4.9/api-reference/resolvers.html

mentamarindo
  • 539
  • 9
  • 16