具有嵌套输入的模式的相应graphql-tag?

问题描述 投票:2回答:1

我正在关注graphql上的教程(这里:https://www.howtographql.com/graphql-js/5-authentication/)并遇到嵌套输入的变异。我该如何编写相应的graphql-tag?

gql``  

架构:

type Mutation {
  createUser(name: String!, authProvider: AuthProviderSignupData!): User
}
###########
## Inputs
###########

input AuthProviderEmail {
  email: String!
  password: String!
}

input AuthProviderSignupData {
  email: AuthProviderEmail
}

对应的graphiql输入:

mutation CreateUser {
  createUser(name: "tester2", authProvider: {email: {email: "[email protected]", password: "password"}}) {
    id
    name
  }
}
apollo graphql-js react-apollo graphcool
1个回答
2
投票
const mutation = gql`
   mutation createUser($authProvider: AuthProviderSignupData!, $name: String!) {
     createUser(authProvider: $authProvider, name: $name) {
       id
     }
   }
`

const variables = {
    "authProvider": {
      "email": {
         "email": "[email protected]",
          "password": "123456789"
         }
      },
     "name": "chakri",      
    } 
© www.soinside.com 2019 - 2024. All rights reserved.