Skip to content

Instantly share code, notes, and snippets.

@SachaG
Created April 14, 2017 04:06
Show Gist options
  • Save SachaG/e9cf798ae62d809cffb288846b5150f4 to your computer and use it in GitHub Desktop.
Save SachaG/e9cf798ae62d809cffb288846b5150f4 to your computer and use it in GitHub Desktop.
let mutation;
if (args) {
const args1 = _.map(args, (type, name) => `$${name}: ${type}`); // e.g. $url: String
const args2 = _.map(args, (type, name) => `${name}: $${name}`); // e.g. $url: url
mutation = `
mutation ${name}(${args1}) {
${name}(${args2})
}
`
} else {
mutation = `
mutation ${name} {
${name}
}
`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment