graphql-clear
v3.4.5
Published
Clear **optional** input fields and arguments if empty
Downloads
8
Readme
Graphql Clear
Clear optional input fields and arguments if empty
notice
The required arguments will not be clear
for example:
$email: String!
Installation
npm install graphql-clear
Usage
var gql = require('graphql-tag')
var clear = require('graphql-clear')
var doc = gql`
mutation(
$username: String!
$password: String!
$email: String!
$file: Upload
) {
createUser(
input: {
fields: {
username: $username
password: $password
email: $email
avatar: { upload: $file }
}
}
) {
user {
id
username
email
avatar {
url
}
}
}
}
`
var data = {
username: "admin",
password: "password"
}
var cleared_doc = clear(doc, data)
cleared_doc
mutation(
$username: String!
$password: String!
$email: String!
) {
createUser(
input: {
fields: {
username: $username
password: $password
email: $email
}
}
) {
user {
id
username
email
avatar {
url
}
}
}
}