GraphQL constructor

GraphQL(
  1. GraphQLSchema schema,
  2. {bool introspect = true,
  3. FutureOr<T> defaultFieldResolver<T>(
    1. T,
    2. String?,
    3. Map<String, dynamic>
    )?,
  4. List<GraphQLType> customTypes = const <GraphQLType>[]}
)

Implementation

GraphQL(GraphQLSchema schema,
    {bool introspect = true,
    this.defaultFieldResolver,
    List<GraphQLType> customTypes = const <GraphQLType>[]})
    : _schema = schema {
  if (customTypes.isNotEmpty == true) {
    this.customTypes.addAll(customTypes);
  }

  var allTypes = fetchAllTypes(schema, [...this.customTypes]);

  if (introspect) {
    _schema = reflectSchema(_schema, allTypes);
  }

  for (var type in allTypes.toSet()) {
    if (!this.customTypes.contains(type)) {
      if (type != null) {
        this.customTypes.add(type);
      }
    }
  }

  if (_schema.queryType != null) {
    this.customTypes.add(_schema.queryType!);
  }
  if (_schema.mutationType != null) {
    this.customTypes.add(_schema.mutationType!);
  }
  if (_schema.subscriptionType != null) {
    this.customTypes.add(_schema.subscriptionType!);
  }
}