2016-07-10 6 views
2

私は、接続の種類があります:クエリで私は(前、後、最後に、最初の)だけを指定することができ、この場合追加の引数に「connectionArgs」リレーJS

let usersType = new GraphQLObjectType({ 
    name: 'Users', 
    description: 'users array', 
    fields:() => ({ 
     array: { 
      type: userConnection, 
      description: 'all users', 
      args: connectionArgs, 
      searchFor: { 
       type: GraphQLString 
      }, 
      resolve: (root, args) => { 
       return connectionFromArray(get(), args); 
      } 
     } 
    }) 
}); 

引数が、何であれば、私は必要なのuserNameなどの追加の引数を渡すことは可能ですか?

基本的に私のようなものが必要です

query { 
    array (first: 1, userName: "name") 
} 

を、ユーザーでは、私は次のようにリクエストを処理することができます入力します。

resolve: (root, args) => connectionFromArray(get(args.userName), args.args) 

答えて

4

はい、それはあなただけで新しいとリレーヘルパーconnectionArgsを拡張する必要があり、可能ですこのような引数:

args: { 
    ...connectionArgs, 
    searchFor: { type: GraphQLString } 
} 

そして、resolve機能:

関連する問題