Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dyedgreen/juniper-relay
Relay style pagination for Juniper
https://github.com/dyedgreen/juniper-relay
graphql juniper relay rust-lang
Last synced: about 1 month ago
JSON representation
Relay style pagination for Juniper
- Host: GitHub
- URL: https://github.com/dyedgreen/juniper-relay
- Owner: dyedgreen
- License: mit
- Created: 2022-10-15T11:47:41.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-15T11:55:59.000Z (about 2 years ago)
- Last Synced: 2024-10-03T06:08:42.361Z (about 2 months ago)
- Topics: graphql, juniper, relay, rust-lang
- Language: Rust
- Homepage: https://crates.io/crates/juniper_relay_connection
- Size: 6.84 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Juniper Relay Connections
[![crates.io](https://img.shields.io/crates/v/juniper_relay_connection.svg)](https://crates.io/crates/juniper_relay_connection)
[![Released API docs](https://docs.rs/juniper_relay_connection/badge.svg)](https://docs.rs/juniper_relay_connection)
[![CI](https://github.com/dyedgreen/juniper-relay/actions/workflows/ci.yml/badge.svg)](https://github.com/dyedgreen/juniper-relay/actions/workflows/ci.yml)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)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][spec].## Example
```rust
#[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 = run_query(sql);
Ok(edges)
})
```[spec]: https://relay.dev/graphql/connections.htm