cynic-parser 0.11.1

A fast, correct and easy to use GraphQL parser
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::type_system::Definition;

#[derive(PartialOrd, Ord, PartialEq, Eq)]
pub(super) enum DefinitionSortKey<'a> {
    Directive(&'a str),
    Type(&'a str, bool),
    Schema(bool),
}

pub(super) fn sort_key_for<'a>(definition: &Definition<'a>) -> DefinitionSortKey<'a> {
    match definition {
        Definition::Schema(_) => DefinitionSortKey::Schema(false),
        Definition::SchemaExtension(_) => DefinitionSortKey::Schema(true),
        Definition::Type(def) => DefinitionSortKey::Type(def.name(), false),
        Definition::TypeExtension(def) => DefinitionSortKey::Type(def.name(), true),
        Definition::Directive(def) => DefinitionSortKey::Directive(def.name()),
    }
}