getGraphQLInterfaces function

List<Expression> getGraphQLInterfaces(
  1. GeneratorCtx ctx,
  2. InterfaceElement clazz
)

Implementation

List<Expression> getGraphQLInterfaces(
  GeneratorCtx ctx,
  InterfaceElement clazz,
) {
  // if (isInputType(clazz)) {
  //   return [];
  // }
  final List<String> interfaces = getClassConfig(ctx, clazz)?.interfaces ?? [];
  final superType = clazz.supertype;

  String getInterfaceName(InterfaceElement element) {
    String name = element.name;
    name = name.startsWith('_') ? name.substring(1) : name;
    final rc = ReCase(name);
    return '${rc.camelCase}$graphqlTypeSuffix';
  }

  // Add interfaces
  return clazz.interfaces
      .where(isGraphQLObject)
      .map((c) => refer(getInterfaceName(c.element)))
      .followedBy(interfaces.map(refer))
      .followedBy(superType != null && isGraphQLObject(superType)
          ? [refer(getInterfaceName(superType.element))]
          : [])
      .toList();
}