juniper_relay_connection 0.1.1

Relay style pagination for Juniper.
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented1 out of 9 items with examples
  • Size
  • Source code size: 45.69 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m Average build duration of successful builds.
  • all releases: 1m Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dyedgreen/juniper-relay
    5 1 2
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dyedgreen

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

#[derive(GraphQLObject)]
struct Foo {
  id: i32,
}

impl RelayConnectionNode for Foo {
    type Cursor = i32;
    fn cursor(&self) -> Self::Cursor {
        self.id
    }
    fn connection_type_name() -> &'static str {
        "FooConnection"
    }
    fn edge_type_name() -> &'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<Foo> = run_query(sql);
    Ok(edges)
})