private static ITypeReference CreateConnectionTypeRef( IDescriptorContext context, MemberInfo?resolverMember, Type?type, PagingOptions options) { // first we will try and infer the schema type from the collection. IExtendedType schemaType = PagingHelper.GetSchemaType( context.TypeInspector, resolverMember, type); // we need to ensure that the schema type is a valid output type. For this we create a // type info which decomposes the type into its logical type components and is able // to check if the named type component is really an output type. if (!context.TypeInspector.TryCreateTypeInfo(schemaType, out ITypeInfo? typeInfo) || !typeInfo.IsOutputType()) { throw PagingObjectFieldDescriptorExtensions_InvalidType(); } options = context.GetSettings(options); // once we have identified the correct type we will create the // paging result type from it. IExtendedType connectionType = context.TypeInspector.GetType( options.IncludeTotalCount ?? false ? typeof(ConnectionCountType <>).MakeGenericType(schemaType.Source) : typeof(ConnectionType <>).MakeGenericType(schemaType.Source)); // last but not leas we create a type reference that can be put on the field definition // to tell the type discovery that this field needs this result type. return(TypeReference.Create(connectionType, TypeContext.Output)); }