ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
use crate::OrderDirection;

/// The bridge to the builder's flag, both ways.
///
/// Two assertions over a two-armed function, and they earn their place because the failure they
/// catch is SILENT: an inverted arm renders `ORDER BY x ASC` for a client that asked for `DESC`,
/// which is a wrong result set reported as a right one — no type mismatch, no error, and nothing
/// downstream that could notice.
#[test]
fn the_flag_the_ordering_seam_takes_says_descending_for_desc_alone() {
  assert!(OrderDirection::Desc.is_descending());
  assert!(!OrderDirection::Asc.is_descending());
}

/// THE SCHEMA PUBLISHES NO DESCRIPTION FOR THIS TYPE, and the assertion is a real one rather than a
/// tidiness: before the `cfg_attr(doc, …)` guard the derive lifted this enum's whole rustdoc into
/// its registry entry, so every schema built on the framework shipped a paragraph naming polarsync
/// and `crate::Id` to clients who have neither.
///
/// Read out of a REAL `Schema`'s SDL rather than off the registry, because the SDL is what a client
/// actually receives — and the two words are searched for by name so that a reworded paragraph
/// reaching the wire is caught by the same test.
#[cfg(feature = "async-graphql")]
#[test]
fn the_direction_publishes_no_description_of_its_own_design() {
  use async_graphql::{EmptyMutation, EmptySubscription, Object, Schema};

  #[derive(Debug, Clone, Copy, PartialEq, Eq, async_graphql::OneofObject)]
  enum Sorted {
    Title(OrderDirection),
  }

  struct Query;

  #[Object]
  impl Query {
    async fn rows(&self, sort: Sorted) -> bool {
      matches!(sort, Sorted::Title(direction) if direction.is_descending())
    }
  }

  let sdl = Schema::new(Query, EmptyMutation, EmptySubscription).sdl();
  let at = sdl
    .find("enum OrderDirection")
    .unwrap_or_else(|| panic!("`OrderDirection` is in the schema: {sdl}"));
  assert!(
    !sdl[..at].trim_end().ends_with("\"\"\""),
    "`OrderDirection` carries a description block: {sdl}"
  );
  for word in ["polarsync", "crate::Id", "unwrap_or_default"] {
    assert!(!sdl.contains(word), "the SDL published `{word}`: {sdl}");
  }
  assert!(
    sdl.contains("ASC") && sdl.contains("DESC"),
    "the VALUES are still published — only their prose is not: {sdl}"
  );
}