fieldFromParam function

Future<FieldInfo> fieldFromParam(
  1. GeneratorCtx ctx,
  2. GraphQLObject? clazz,
  3. ParameterElement param, {
  4. required bool isInput,
  5. required Map<String, TypeParameterElement> generics,
})

Implementation

Future<FieldInfo> fieldFromParam(
  GeneratorCtx ctx,
  GraphQLObject? clazz,
  ParameterElement param, {
  required bool isInput,
  required Map<String, TypeParameterElement> generics,
}) async {
  final annot = getFieldAnnot(clazz, param);

  return FieldInfo(
    gqlType: annot.type != null
        ? refer(annot.type!)
        : inferType(
            ctx.config.customTypes,
            param,
            param.name,
            param.type,
            nullable: annot.nullable,
            isInput: isInput,
            generics: generics,
          ),
    name: annot.name ?? param.name,
    defaultValueCode: getDefaultValue(param),
    getter: param.name,
    isMethod: false,
    inputs: [],
    nonNullable: annot.nullable != true && !param.isOptional,
    fieldAnnot: annot,
    description: await documentationOfParameter(param, ctx.buildStep),
    deprecationReason: getDeprecationReason(param),
    attachments: getAttachments(param),
  );
}