Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stephenplusplus/d89029800b60a656c4cb2d2ca0f6655e to your computer and use it in GitHub Desktop.
Save stephenplusplus/d89029800b60a656c4cb2d2ca0f6655e to your computer and use it in GitHub Desktop.
var flatten = require('lodash.flatten')
var prop = require('propprop')
var requests = [
{
mutations: [
{ a: 'b' },
{ c: 'd' }
]
},
{
mutations: [
{ e: 'f' },
{ g: 'h' }
]
}
]
var reqOpts = {
mutations: flatten(requests.map(prop('mutations')))
}
assert.deepEqual(reqOpts, {
mutations: [
{ a: 'b' },
{ c: 'd' },
{ e: 'f' },
{ g: 'h' }
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment