platform/packages/graphql/graphql_schema/lib/src/gen.dart
Tobe O 4e69153e3e Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca'
git-subtree-dir: packages/graphql
git-subtree-mainline: ac29392d7f
git-subtree-split: 33e2f86ba7
2020-02-15 18:22:07 -05:00

49 lines
1.6 KiB
Dart

part of graphql_schema.src.schema;
/// Shorthand for generating a [GraphQLObjectType].
GraphQLObjectType objectType(String name,
{String description,
bool isInterface: false,
Iterable<GraphQLObjectField> fields = const [],
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;
}
/// Shorthand for generating a [GraphQLObjectField].
GraphQLObjectField<T, Serialized> field<T, Serialized>(
String name, GraphQLType<T, Serialized> type,
{Iterable<GraphQLFieldInput<T, Serialized>> inputs: const [],
GraphQLFieldResolver<T, Serialized> resolve,
String deprecationReason,
String description}) {
return new GraphQLObjectField<T, Serialized>(name, type,
arguments: inputs,
resolve: resolve,
description: description,
deprecationReason: deprecationReason);
}
/// Shorthand for generating a [GraphQLInputObjectType].
GraphQLInputObjectType inputObjectType(String name,
{String description,
Iterable<GraphQLInputObjectField> inputFields: const []}) {
return new GraphQLInputObjectType(name,
description: description, inputFields: inputFields);
}
/// Shorthand for generating a [GraphQLInputObjectField].
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);
}