pub fn node_count(
document: &str,
variables: &Variables,
) -> Result<u64, NodeCountError>Expand description
The worst-case number of nodes the one operation in document may return,
under variables, computed by GitHub’s published rules.
The document must hold exactly one operation. Fragment definitions beside it are resolved, so the natural consumer shape — one shared fragment concatenated onto each of several operations, giving several single-operation documents — is counted correctly, once per document.
§Errors
Returns NodeCountError rather than panicking, returning zero, or
returning a wrong count, when:
- the text does not parse as GraphQL (
NodeCountError::Parse); - the document declares no operation (
NodeCountError::NoOperation); - it declares more than one, which this signature cannot disambiguate
(
NodeCountError::MultipleOperations); - a
first:/last:names a variablevariablesdoes not bind (NodeCountError::UnboundVariable); - a
first:/last:value falls outside1..=100(NodeCountError::PageSizeOutOfRange) or is not an integer at all (NodeCountError::PageSizeNotAnInteger); - a spread names a fragment the document does not define
(
NodeCountError::UndefinedFragment), or the spreads form a cycle (NodeCountError::FragmentCycle); - the count grows past
u64(NodeCountError::Overflow), which only a document far aboveNODE_LIMITcan do.