[英]How do you write your graphql mutations testable in ruby?
When you create a mutation, you usually follow this guide and create one with GraphQL::Relay::Mutation.define
创建突变时,通常遵循本指南并使用
GraphQL::Relay::Mutation.define
创建一个
http://graphql-ruby.org/relay/mutations.html http://graphql-ruby.org/relay/mutations.html
I found this website, and this explains another approach to create a mutation by using GraphQL::Function
我找到了这个网站,这解释了使用
GraphQL::Function
创建变异的另一种方法
https://www.howtographql.com/graphql-ruby/3-mutations/ https://www.howtographql.com/graphql-ruby/3-mutations/
http://graphql-ruby.org/fields/function.html http://graphql-ruby.org/fields/function.html
GraphQL::Function
looks so much easier to test, but I am not sure if I will lose some functionalities compared to a mutation defined by GraphQL::Relay::Mutation.define
. GraphQL::Function
看起来很容易测试,但是与GraphQL::Relay::Mutation.define
定义的突变相比,我不确定是否会丢失某些功能。
Are there any differences when to use from the client side? 从客户端使用时,有什么区别吗?
i think this way is more easy, in mutation_type.rb 我认为在mutation_type.rb中这种方法更容易
Types::MutationType = GraphQL::ObjectType.define do
name "Mutation"
field :yourMutation, yourType do
argument :field, type_of_field
resolve -> (obj, args, ctx){
#do whatever you want
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.