Docs on GraphQLObjectField

This commit is contained in:
Tobe O 2018-08-04 21:59:31 -04:00
parent 27c167fc50
commit 44342cbdf8

View file

@ -1,14 +1,30 @@
part of graphql_schema.src.schema;
/// Typedef for a function that resolves the value of a [GraphQLObjectField], whether asynchronously or not.
typedef FutureOr<Value> GraphQLFieldResolver<Value, Serialized>(
Serialized serialized, Map<String, dynamic> argumentValues);
/// A field on a [GraphQLObjectType].
///
/// It can have input values and additional documentation, and explicitly declares it shape
/// within the schema.
class GraphQLObjectField<Value, Serialized> {
/// The list of input values this field accepts, if any.
final List<GraphQLFieldInput> inputs = <GraphQLFieldInput>[];
/// The name of this field in serialized input.
final String name;
/// A function used to evaluate the value of this field, with respect to an arbitrary Dart value.
final GraphQLFieldResolver<Value, Serialized> resolve;
/// The [GraphQLType] associated with values that this field's [resolve] callback returns.
final GraphQLType<Value, Serialized> type;
/// An optional description of this field; useful for tools like GraphiQL.
final String description;
/// The reason that this field, if it is deprecated, was deprecated.
final String deprecationReason;
GraphQLObjectField(this.name, this.type,
@ -22,6 +38,7 @@ class GraphQLObjectField<Value, Serialized> {
this.inputs.addAll(arguments ?? <GraphQLFieldInput>[]);
}
/// Returns `true` if this field has a [deprecationReason].
bool get isDeprecated => deprecationReason?.isNotEmpty == true;
FutureOr<Serialized> serialize(Value value) {