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

Implementing Relay-compatible connections #37

Open
singingwolfboy opened this issue Sep 2, 2018 · 0 comments
Open

Implementing Relay-compatible connections #37

singingwolfboy opened this issue Sep 2, 2018 · 0 comments

Comments

@singingwolfboy
Copy link
Contributor

Hi there, Vesper looks like a useful framework, and I'm trying to use it for my app. However, I can't figure out how to implement Relay-compatible connections in my resolvers; the type signature seems to expect that I will return either a list of database entities, or a promise that returns that. Instead, I need to return a plain JavaScript object with at least the following information:

{
  edges: [
    {
      node: entity,
      cursor: encodeCursor(entity)
    },
    // ...repeated as necessary
  ],
  pageInfo: {
    hasPreviousPage,
    hasNextPage,
    startCursor,
    endCursor,
    totalCount
  }
}

where entity is the database entity, and encodeCursor is a function that returns a cursor string so that a subsequent API call can paginate starting from that entity.

Is it possible to do this? And if so, how? Can you provide a code example? I'm happy to provide my code, if you need.

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

No branches or pull requests

1 participant