Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing functionality to flatten array #10

Closed
MrLoh opened this issue Oct 28, 2017 · 5 comments
Closed

missing functionality to flatten array #10

MrLoh opened this issue Oct 28, 2017 · 5 comments

Comments

@MrLoh
Copy link

MrLoh commented Oct 28, 2017

I have the following query:

movie {
  cast {
    id
    role
    person {
      actorId: id
      fullName
    }
  }
}

Now I would like to flatten the cast into an array of not-nested objects.

movie {
  cast {
    id
    role
    actorId
    fullName
  }
}

It seems like lodash can't do that. Would be nice to add a functionality, maybe like:

movie {
  cast @_(flattenObjectDepth: 1) {
    id
    role
    person {
      actorId: id
      fullName
    }
  } 
}

I could create a PR, with a little help as to how transformations need to look like.

@IvanGoncharov
Copy link
Member

@MrLoh I need to think about it and how to make it more readable.
Maybe add separate @spread directive, like this:

movie {
  cast {
    id
    role
    person @spread {
      actorId: id
      fullName
    }
  } 
}

What do you think?

@IvanGoncharov
Copy link
Member

@MrLoh On a second thought create separate directives for every transformation is a bad idea.
Thanks to @RomanGotsiy for explaining this to me.
Need to think a little bit more about this...

@MrLoh
Copy link
Author

MrLoh commented Nov 1, 2017

I like the spread idea, it's just a very common task in graphql I think, that's missing from lodash.

@MrLoh
Copy link
Author

MrLoh commented Nov 10, 2017

This would probably be best covered by #9 as well, maybe we should close this?

@IvanGoncharov
Copy link
Member

@MrLoh Agree 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants