classInfoFromConstructor function
Future<UnionVarianInfo>
classInfoFromConstructor(
- GeneratorCtx ctx,
- InterfaceElement clazz,
- ConstructorElement con, {
- required bool isUnion,
- required Iterable<
Future< unionClassFields,FieldInfo> > - GraphQLInput? inputConfig,
- GraphQLObject? classConfig,
Implementation
Future<UnionVarianInfo> classInfoFromConstructor(
GeneratorCtx ctx,
InterfaceElement clazz,
ConstructorElement con, {
required bool isUnion,
required Iterable<Future<FieldInfo>> unionClassFields,
GraphQLInput? inputConfig,
GraphQLObject? classConfig,
}) async {
final className = ReCase(clazz.name).pascalCase;
final redirectedName = con.redirectedConstructor?.returnType
.getDisplayString(withNullability: false) ??
con.name;
final generics = Map.fromEntries(
clazz.typeParameters.map((e) => MapEntry(e.name, e)),
);
return UnionVarianInfo(
isInterface: isInterface(clazz),
typeParams: clazz.typeParameters,
hasFrezzed: true,
isUnion: isUnion,
interfaces: getGraphQLInterfaces(ctx, clazz),
hasFromJson: hasFromJson(clazz),
classConfig: classConfig,
typeName: isUnion ? redirectedName : className,
constructorName: isUnion ? con.name : redirectedName,
unionName: className,
inputConfig: inputConfig,
description: getDescription(con, con.documentationComment),
deprecationReason: getDeprecationReason(con),
fields: await Future.wait(
con.parameters
.map((p) => fieldFromParam(
ctx,
classConfig,
p,
isInput: inputConfig != null,
generics: generics,
))
.followedBy(unionClassFields),
),
attachments: getAttachments(clazz),
);
}