title: Add filtering to schemas created dynamically with hotchocolate (GraphQL)
body: <p>I'm using the new interface (ITypeModule) introduced on the latest version of the hotchocolate framework (v12) to dynamically create all types of my schema. (<a href="https://chillicream.com/blog/2021/09/27/hot-chocolate-12#dynamic-schemas" rel="nofollow noreferrer">https://chillicream.com/blog/2021/09/27/hot-chocolate-12#dynamic-schemas</a>)</p>
  <p>It's working well. But now I'm struggling to find out how to add filtering on my types using this stategy (since I can't use anotations and neither the descriptor like its done on the documentation (<a href="https://chillicream.com/docs/hotchocolate/fetching-data/filtering" rel="nofollow noreferrer">https://chillicream.com/docs/hotchocolate/fetching-data/filtering</a>)</p>
  <p>What I've tried so far:</p>
  <p>My dependency injection:</p>
  <pre><code>// code omitted 
  builder.Services
         .AddGraphQLServer()
         .AddTypeModule&lt;DynamicTenantSchemaTypeModule&gt;()
         .AddFiltering();
  </code></pre>
  <p>On the ITypeModule implementation (DynamicTenantSchemaTypeModule):</p>
  <pre><code>    //code omitted
      public async ValueTask&lt;IReadOnlyCollection&lt;ITypeSystemMember&gt;&gt; CreateTypesAsync(IDescriptorContext context, CancellationToken cancellationToken)
      {
              var types = new List&lt;ITypeSystemMember&gt;();
              var queryType = new ObjectTypeDefinition(&quot;Query&quot;);
              var schemas = await _documentSchemaRepository.GetSchemasAsync();
              foreach (var schema in schemas)
              {
                  var schemaNamePascalCase = schema.Name!.ToPascalCase();
                  var schemaNamePluralCamelCase = schema.PluralName!.ToCamelCase();
                  var objectTypeDefinition = new ObjectTypeDefinition(schemaNamePascalCase);
                  await AddFieldsAsync(types, schema, objectTypeDefinition, schema.Properties);
                  queryType.Fields.Add(new ObjectFieldDefinition(schemaNamePluralCamelCase)
                  {
                      Type = TypeReference.Parse($&quot;[{schemaNamePascalCase}]&quot;),
                      Resolver = async (ctx) =&gt;
                      {
                          var documents = await _documentRepository.GetDocumentsAsync(schema.Id);
                          return documents;
                      }
                  }
                  .ToDescriptor(context)
                  .UseFiltering()
                  .ToDefinition());
                  types.Add(ObjectType.CreateUnsafe(objectTypeDefinition));
              }
              types.Add(ObjectType.CreateUnsafe(queryType));
              return types;
  }
  //code omitted
  </code></pre>
  <p>But it throws the following exception:</p>
  <pre><code>HotChocolate.SchemaException: For more details look at the `Errors` property.
  
  1. No default filter convention found. Call `AddFiltering()` on the schema builder.
  
     at HotChocolate.Data.FilterDescriptorContextExtensions.&lt;&gt;c__DisplayClass1_0.&lt;GetFilterConvention&gt;b__0()
     at HotChocolate.Types.Descriptors.DescriptorContext.GetConventionOrDefault[T](Func`1 defaultConvention, String scope)
     at HotChocolate.Data.FilterDescriptorContextExtensions.GetFilterConvention(IDescriptorContext context, String scope)
     at HotChocolate.Types.FilterObjectFieldDescriptorExtensions.&lt;&gt;c__DisplayClass5_0.&lt;UseFiltering&gt;b__1(IDescriptorContext c, ObjectFieldDefinition definition)
     at HotChocolate.Types.Descriptors.DescriptorBase`1.&lt;&gt;c__DisplayClass19_0.&lt;OnBeforeCreate&gt;b__0(IDescriptorContext c, IDefinition d)
     at HotChocolate.Types.Descriptors.DescriptorBase`1.CreateDefinition()
     at HotChocolate.Types.Descriptors.DescriptorExtensions.ToDefinition[T](IDescriptor`1 descriptor)
  </code></pre>
  <p>Any ideas on how to add the filtering middleware correctly? Thanks!</p>