Juniper Relay Connections

crates.io Released API docs CI MIT licensed

Relay style pagination for Juniper.

This library provides the a RelayConnection struct, which can be returned in a Juniper GraphQL schema and implements the relay connection interface.

Example

```rust

[derive(GraphQLObject)]

struct Foo { id: i32, }

impl RelayConnectionNode for Foo { type Cursor = i32; fn cursor(&self) -> Self::Cursor { self.id } fn connectiontypename() -> &'static str { "FooConnection" } fn edgetypename() -> &'static str { "FooConnectionEdge" } }

RelayConnection::new(first, after, last, before, |after, before, limit| { let sql = format!("SELECT (id) FROM foo WHERE id > {after} AND id < {before} LIMIT {limit}"); let edges: Vec = run_query(sql); Ok(edges) }) ```