hive-router 0.2.0

GraphQL router for Federation, part of the Hive platform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

use crate::query_planner::ast::hash::ASTHash;
use crate::query_planner::ast::selection_set::SelectionSet;

#[derive(Hash, PartialEq, Eq, Copy, Clone)]
pub struct SelectionId(u64);

pub fn generate_selection_id(type_name: &str, selection_set: &SelectionSet) -> SelectionId {
    let mut hasher = DefaultHasher::new();
    type_name.hash(&mut hasher);
    selection_set.ast_hash::<_, true>(&mut hasher);
    SelectionId(hasher.finish())
}