具有嵌套输入的模式的相应 graphql 标签?
Corresponding graphql-tag for a schema with nested inputs?
我正在学习有关 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: "test@test.com", password: "password"}}) {
id
name
}
}
const mutation = gql`
mutation createUser($authProvider: AuthProviderSignupData!, $name: String!) {
createUser(authProvider: $authProvider, name: $name) {
id
}
}
`
const variables = {
"authProvider": {
"email": {
"email": "chakri@example.com",
"password": "123456789"
}
},
"name": "chakri",
}
我正在学习有关 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: "test@test.com", password: "password"}}) {
id
name
}
}
const mutation = gql`
mutation createUser($authProvider: AuthProviderSignupData!, $name: String!) {
createUser(authProvider: $authProvider, name: $name) {
id
}
}
`
const variables = {
"authProvider": {
"email": {
"email": "chakri@example.com",
"password": "123456789"
}
},
"name": "chakri",
}