def select_field(query, *, args): if args.first < 0: raise g.GraphError( "first must be non-negative integer, was {}".format( args.first)) else: return ConnectionQuery(type_query=query, first=args.first, after=args.after)
def read_result(self, value): if len(value) == 0: return None elif len(value) == 1: return value[0] else: raise g.GraphError( "expected exactly zero or one values but got {}".format( len(value)))
def read_results(self, iterable): result = collections.defaultdict(lambda: None) for key, value in iterable: if key in result: raise g.GraphError("expected exactly zero or one values") else: result[key] = value return result
def read_results(self, iterable): result = {} for key, value in iterable: if key in result: raise g.GraphError("expected exactly one value") else: result[key] = value return result
def get_field(field_query): if field_query.field == schema.typename_field and isinstance( query.type, schema.ObjectType): return _ConstantField(query.type.name) else: field = fields().get(field_query.field) if field is None: raise g.GraphError("Resolver missing for field {}".format( field_query.field.name)) elif callable(field): # TODO: test dependencies are injected return injector.call_with_dependencies( field, graph, field_query) else: return field
def root_resolve_value(graph, query, args): raise g.GraphError("BAD")