UNPKG

blips

Version:

State management for the GraphQL heads

26 lines (19 loc) 598 B
import { getOperationASTs, } from './getOperationASTs' import { loneAnonymousOperation, uniqueFragmentNames, singleFieldSubscriptions, } from './rules' export function validateWithoutSchema (document) { const operationCount = getOperationASTs(document).length const knownFragmentNames = Object.create(null) let errors = [] for (const node of document.definitions) { const err = loneAnonymousOperation(node, operationCount) || uniqueFragmentNames(node, knownFragmentNames) || singleFieldSubscriptions(node) err && errors.push(err) } return errors }