2017-12-19 12 views
1

, 당신은 일반적으로이 가이드를 따라 나는이 웹 사이트를 발견 GraphQL::Relay::Mutation.define
http://graphql-ruby.org/relay/mutations.htmlruby에서 graphql mutations을 어떻게 테스트 할 수 있습니까? 당신이 돌연변이를 만들 때

하나를 만들고,이 GraphQL::Function
https://www.howtographql.com/graphql-ruby/3-mutations/
http://graphql-ruby.org/fields/function.html

을 사용하여 돌연변이를 만드는 또 다른 방법을 설명합니다

GraphQL::Function은 테스트하기가 훨씬 쉬워 보이지만 GraphQL::Relay::Mutation.define으로 정의 된 돌연변이와 비교할 때 일부 기능을 잃을 지 확신 할 수 없습니다.

클라이언트 측에서는 어떤 차이점이 있습니까?

+0

당신은 당신의 돌연변이의 필드의'resolve'을 테스트하고 해결 돌연변이의 영향을 테스트 할 수 있습니다,이 방법은 더 쉽게 생각합니다. 예 :'YourMutationRoot.fields [ 'updateCurrentUser'] .resolution (nil, input, context)'제공된 입력을 문맥에 맞게 해시로 수동 설정합니다. – MrYoshiji

답변

0

은 내가 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 
    }