2018-08-02 13:31:54 +00:00
|
|
|
part of graphql_schema.src.schema;
|
|
|
|
|
2018-08-05 02:09:41 +00:00
|
|
|
/// Shorthand for generating a [GraphQLObjectType].
|
2018-08-02 13:31:54 +00:00
|
|
|
GraphQLObjectType objectType(String name,
|
2018-08-03 23:43:00 +00:00
|
|
|
{String description,
|
|
|
|
bool isInterface: false,
|
2018-08-04 19:18:53 +00:00
|
|
|
Iterable<GraphQLObjectField> fields = const [],
|
2018-08-03 23:43:00 +00:00
|
|
|
Iterable<GraphQLObjectType> interfaces = const []}) {
|
|
|
|
var obj = new GraphQLObjectType(name, description, isInterface: isInterface)
|
|
|
|
..fields.addAll(fields ?? []);
|
|
|
|
|
|
|
|
if (interfaces?.isNotEmpty == true) {
|
|
|
|
for (var i in interfaces) {
|
|
|
|
obj.inheritFrom(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
2018-08-02 13:31:54 +00:00
|
|
|
|
2018-08-05 02:09:41 +00:00
|
|
|
/// Shorthand for generating a [GraphQLObjectField].
|
2018-08-04 19:18:53 +00:00
|
|
|
GraphQLObjectField<T, Serialized> field<T, Serialized>(
|
|
|
|
String name, GraphQLType<T, Serialized> type,
|
|
|
|
{Iterable<GraphQLFieldInput<T, Serialized>> inputs: const [],
|
2018-08-02 13:31:54 +00:00
|
|
|
GraphQLFieldResolver<T, Serialized> resolve,
|
2019-03-29 18:45:02 +00:00
|
|
|
String deprecationReason,
|
|
|
|
String description}) {
|
2018-08-04 19:18:53 +00:00
|
|
|
return new GraphQLObjectField<T, Serialized>(name, type,
|
|
|
|
arguments: inputs,
|
2018-08-05 01:32:20 +00:00
|
|
|
resolve: resolve,
|
2018-08-04 19:18:53 +00:00
|
|
|
description: description,
|
2018-08-03 18:59:31 +00:00
|
|
|
deprecationReason: deprecationReason);
|
2018-08-02 13:31:54 +00:00
|
|
|
}
|
2018-08-04 19:18:53 +00:00
|
|
|
|
2018-08-05 02:09:41 +00:00
|
|
|
/// Shorthand for generating a [GraphQLInputObjectType].
|
2018-08-04 19:18:53 +00:00
|
|
|
GraphQLInputObjectType inputObjectType(String name,
|
|
|
|
{String description,
|
|
|
|
Iterable<GraphQLInputObjectField> inputFields: const []}) {
|
|
|
|
return new GraphQLInputObjectType(name,
|
|
|
|
description: description, inputFields: inputFields);
|
|
|
|
}
|
|
|
|
|
2018-08-05 02:09:41 +00:00
|
|
|
/// Shorthand for generating a [GraphQLInputObjectField].
|
2018-08-04 19:18:53 +00:00
|
|
|
GraphQLInputObjectField<T, Serialized> inputField<T, Serialized>(
|
|
|
|
String name, GraphQLType<T, Serialized> type,
|
|
|
|
{String description, T defaultValue}) {
|
|
|
|
return new GraphQLInputObjectField(name, type,
|
|
|
|
description: description, defaultValue: defaultValue);
|
|
|
|
}
|