f / graphql.js

A Simple and Isomorphic GraphQL Client for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.mutate() does not autodeclare variables

flewellyn opened this issue · comments

When I use the .query() helper method with autodeclare, it works perfectly. However, .mutate() does not autodeclare the variables for input.

I can still use the main function and enter the full mutation syntax, with manual declarations. But having the helper method work properly would be nice.

Yes, mutate cannot autodeclare input.

You should use field!Type syntax to help autodeclaration.

    graph.mutate(gql`(@autodeclare) {
      userCreate(input: $input) {
        user {
          ...userInfo
        }
      }
    }`, { 'input!UserCreateInput': { name: "Fatih", surname: "Akin" } });

Ahh, I see. Yes, this works nicely. Thank you.