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

Connection with edge data #50

Closed
michaelbeaumont opened this issue Apr 21, 2020 · 7 comments · Fixed by #51
Closed

Connection with edge data #50

michaelbeaumont opened this issue Apr 21, 2020 · 7 comments · Fixed by #51
Labels

Comments

@michaelbeaumont
Copy link
Contributor

We're trying to tweak graphql-compose-connection to add data to the edges.
Concretely, we have an m-to-n relationship in mongo linking to collections X and Y using a collection XY which has data itself:

XY = new mongoose.Schema({
  xId: ObjectId,
  yId: ObjectId,
  kind: String,
})

Ideally, I'd like to have the following schema:

xs {
  <x fields>
  ys {
    edges {
      kind  // <- comes from `XY`
      node {
        <y fields>
      }
    }
  }
}

How could graphql-compose-connection support this?

Some things aren't clear, like how to do filtering, how to deal with indexes.

Our current idea for filtering would allow for something like:

ys(filter: { node: {<y fields>}, edge: { kind: "kind1" } }) {

where I can do filtering both on the edge and the node.

What do you think? We have a WIP

@nodkz
Copy link
Member

nodkz commented Apr 21, 2020

For such complex case, I recommend you write field resolver from scratch. It will be faster and more configurable.

Also, you may try to use addRelation method:

But I found that addRelations complex in some situations and it's may lead to some complex debuggable situations.

So don't get in trap with code generation with such case. Just write such resolver manually and you save your time.

1 similar comment
@nodkz
Copy link
Member

nodkz commented Apr 21, 2020

For such complex case, I recommend you write field resolver from scratch. It will be faster and more configurable.

Also, you may try to use addRelation method:

But I found that addRelations complex in some situations and it's may lead to some complex debuggable situations.

So don't get in trap with code generation with such case. Just write such resolver manually and you save your time.

@michaelbeaumont
Copy link
Contributor Author

The point of using connection would be to get all of the pagination, cursor etc "for free".
My plan at the moment is to write the resolver manually, but some tweaks to connection are needed, for creating the edge type and tweaking the output to match that type.

@nodkz
Copy link
Member

nodkz commented Apr 22, 2020

Open PR and let discuss proposed changes.

PS. we should try to keep runtime changes as small as possible for this package. we should try to avoid performance degradation.

@PeteMac88
Copy link
Contributor

Open PR and let discuss proposed changes.

PS. we should try to keep runtime changes as small as possible for this package. we should try to avoid performance degradation.

Hey, any news when you will have a look at the proposed changes in the PR?

@nodkz nodkz closed this as completed in #51 May 5, 2020
nodkz pushed a commit that referenced this issue May 5, 2020
* Add ability to add fields to edges

* Add connectionResolver with edgeFields to tests
@nodkz
Copy link
Member

nodkz commented May 5, 2020

@michaelbeaumont sorry for the delay. I completely lose your PR. Sorry! 🙏
@PeteMac88 thanks for pinging me 👍

@nodkz
Copy link
Member

nodkz commented May 5, 2020

🎉 This issue has been resolved in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants