【问题标题】:How can i insert multiple data on same mutation in Laravel Lighthouse?如何在 Laravel Lighthouse 中插入多个相同突变的数据?
【发布时间】:2020-03-30 02:34:53
【问题描述】:

我可以在同一个突变上插入多个吗?

我想知道这是否存在。

这是我的架构

type Test {
    id: ID
    name: String
    msg: String
}

input testInput {
    name: String
    msg: String
}

type Mutation {
    createTest(input: [testInput]): [Test] @create
}

这是我的变异查询

mutation{
    createTest(input: [
        {id:1,  name: "test", msg:"hahaha",},
        {id:2, name: "test2", msg:"hahahaa" }
    ]) {
        id
        name
        msg
    }
}

【问题讨论】:

    标签: laravel-lighthouse


    【解决方案1】:

    您可以使用自定义突变:

    php artisan lighthouse:mutation CreateTest
    

    如果你想要一些可重用的东西,你可能想要实现一个自定义字段解析器指令。查看@create 的实现,了解如何实现。

    【讨论】:

    • 我研究了@create 的实现。我解决了!谢谢!
    猜你喜欢
    • 2020-12-25
    • 2020-08-15
    • 1970-01-01
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 2020-08-18
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多