0

我想使用 Laravel 创建事件来更改突变。我想从来自前端的键中获取任务 ID。然后我想添加这个 ID 来代替键,这样我的任务将使用灯塔结构自动创建。这是样本突变

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

1 回答 1

0

我的建议是为您的具体情况创建一个解析器:

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

请记住始终使用双引号“”,切勿使用单引号''

在你的 schema.graphql

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

type newUserResponse {
    ID: ID!
}

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

这是解析器的示例:解析器示例

还要检查文档:https ://lighthouse-php.com/4.9/api-reference/resolvers.html

于 2020-07-17T13:17:55.480 回答