Skip to content

Commit

Permalink
Remove ReadOnly Schema Options Wrapper (#6653)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Nov 1, 2023
1 parent bf74176 commit 3501daa
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 310 deletions.
24 changes: 18 additions & 6 deletions src/HotChocolate/Core/src/Types/Configuration/TypeInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public abstract class TypeInterceptor

internal virtual void SetSiblings(TypeInterceptor[] all) { }

[Obsolete("The schema builder is obsolete and will be removed in the next version.", error: true)]
public virtual void OnBeforeCreateSchema_(
[Obsolete("This hook is deprecated and will be removed in the next release.")]
internal virtual void OnBeforeCreateSchema(
IDescriptorContext context,
ISchemaBuilder schemaBuilder) { }

// note: this hook is a legacy hook and will be removed once the new schema building API is completed.
/// <summary>
/// This hook is invoked before anything else any allows for additional modification
/// with the schema builder.
Expand All @@ -48,7 +49,12 @@ public virtual void OnBeforeCreateSchema_(
/// </param>
internal virtual void OnBeforeCreateSchemaInternal(
IDescriptorContext context,
ISchemaBuilder schemaBuilder) { }
ISchemaBuilder schemaBuilder)
{
#pragma warning disable CS0618 // Type or member is obsolete
OnBeforeCreateSchema(context, schemaBuilder);
#pragma warning restore CS0618 // Type or member is obsolete
}

internal virtual void InitializeContext(
IDescriptorContext context,
Expand Down Expand Up @@ -265,9 +271,10 @@ public virtual void OnValidateType(

public virtual void OnTypesCompleted() { }

[Obsolete("The schema builder is obsolete and will be removed in the next version.", error: true)]
public virtual void OnAfterCreateSchema_(IDescriptorContext context, ISchema schema) { }
[Obsolete("This hook is deprecated and will be removed in the next release.")]
public virtual void OnAfterCreateSchema(IDescriptorContext context, ISchema schema) { }

// note: this hook is a legacy hook and will be removed once the new schema building API is completed.
/// <summary>
/// This hook is invoked after schema is fully created and gives access
/// to the created schema object.
Expand All @@ -278,7 +285,12 @@ public virtual void OnAfterCreateSchema_(IDescriptorContext context, ISchema sch
/// <param name="schema">
/// The created schema.
/// </param>
internal virtual void OnAfterCreateSchemaInternal(IDescriptorContext context, ISchema schema) { }
internal virtual void OnAfterCreateSchemaInternal(IDescriptorContext context, ISchema schema)
{
#pragma warning disable CS0618 // Type or member is obsolete
OnAfterCreateSchema(context, schema);
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
/// This hook is invoked if an error occured during schema creation.
Expand Down
147 changes: 119 additions & 28 deletions src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,175 @@ namespace HotChocolate;
/// </summary>
public interface IReadOnlySchemaOptions
{
/// <inheritdoc cref="SchemaOptions.QueryTypeName"/>
/// <summary>
/// Gets or sets the name of the query type.
/// </summary>
string? QueryTypeName { get; }

/// <inheritdoc cref="SchemaOptions.MutationTypeName"/>
/// <summary>
/// Gets or sets the name of the mutation type.
/// </summary>
string? MutationTypeName { get; }

/// <inheritdoc cref="SchemaOptions.SubscriptionTypeName"/>
/// <summary>
/// Gets or sets the name of the subscription type.
/// </summary>
string? SubscriptionTypeName { get; }

/// <inheritdoc cref="SchemaOptions.StrictValidation"/>
/// <summary>
/// Defines if the schema allows the query type to be omitted.
/// </summary>
bool StrictValidation { get; }

/// <inheritdoc cref="SchemaOptions.UseXmlDocumentation"/>
/// <summary>
/// Defines if the CSharp XML documentation shall be integrated.
/// </summary>
bool UseXmlDocumentation { get; }

/// <inheritdoc cref="SchemaOptions.ResolveXmlDocumentationFileName"/>
/// <summary>
/// A delegate which defines the name of the XML documentation file to be read.
/// Only used if <seealso cref="UseXmlDocumentation"/> is true.
/// </summary>
Func<Assembly, string>? ResolveXmlDocumentationFileName { get; }

/// <inheritdoc cref="SchemaOptions.SortFieldsByName"/>
/// <summary>
/// Defines if fields shall be sorted by name.
/// Default: <c>false</c>
/// </summary>
bool SortFieldsByName { get; }

/// <inheritdoc cref="SchemaOptions.PreserveSyntaxNodes"/>
/// <summary>
/// Defines if syntax nodes shall be preserved on the type system objects
/// </summary>
bool PreserveSyntaxNodes { get; }

/// <inheritdoc cref="SchemaOptions.RemoveUnreachableTypes"/>
/// <summary>
/// Defines if types shall be removed from the schema that are
/// unreachable from the root types.
/// </summary>
bool RemoveUnreachableTypes { get; }

/// <inheritdoc cref="SchemaOptions.DefaultBindingBehavior"/>
/// <summary>
/// Defines the default binding behavior.
/// </summary>
BindingBehavior DefaultBindingBehavior { get; }

/// <inheritdoc cref="SchemaOptions.DefaultFieldBindingFlags"/>
/// <summary>
/// Defines which members shall be by default inferred as GraphQL fields.
/// This default applies to <see cref="ObjectType"/> and <see cref="ObjectTypeExtension"/>.
/// </summary>
FieldBindingFlags DefaultFieldBindingFlags { get; }

/// <inheritdoc cref="SchemaOptions.FieldMiddleware"/>
/// <summary>
/// Defines on which fields a middleware pipeline can be applied on.
/// </summary>
FieldMiddlewareApplication FieldMiddleware { get; }

/// <inheritdoc cref="SchemaOptions.EnableDirectiveIntrospection"/>
/// <summary>
/// Defines if the experimental directive introspection feature shall be enabled.
/// </summary>
bool EnableDirectiveIntrospection { get; }

/// <inheritdoc cref="SchemaOptions.DefaultDirectiveVisibility"/>
/// <summary>
/// The default directive visibility when directive introspection is enabled.
/// </summary>
DirectiveVisibility DefaultDirectiveVisibility { get; }

/// <inheritdoc cref="SchemaOptions.DefaultResolverStrategy"/>
/// <summary>
/// Defines that the default resolver execution strategy.
/// </summary>
ExecutionStrategy DefaultResolverStrategy { get; }

/// <inheritdoc cref="SchemaOptions.ValidatePipelineOrder"/>
/// <summary>
/// Defines if the order of important middleware components shall be validated.
/// </summary>
bool ValidatePipelineOrder { get; }

/// <inheritdoc cref="SchemaOptions.StrictRuntimeTypeValidation"/>

/// <summary>
/// Defines if the runtime types of types shall be validated.
/// </summary>
bool StrictRuntimeTypeValidation { get; }

/// <inheritdoc cref="SchemaOptions.DefaultIsOfTypeCheck"/>
/// <summary>
/// Defines a delegate that determines if a runtime
/// is an instance of an <see cref="ObjectType{T}"/>.
/// </summary>
IsOfTypeFallback? DefaultIsOfTypeCheck { get; }

/// <inheritdoc cref="SchemaOptions.EnableOneOf"/>
/// <summary>
/// Defines if the OneOf spec RFC is enabled. This feature is experimental.
/// </summary>
bool EnableOneOf { get; }

/// <inheritdoc cref="SchemaOptions.EnsureAllNodesCanBeResolved"/>
/// <summary>
/// Defines if the schema building process shall validate that all nodes are resolvable through `node`.
/// </summary>
bool EnsureAllNodesCanBeResolved { get; }

/// <inheritdoc cref="SchemaOptions.EnableFlagEnums"/>
/// <summary>
/// Defines if flag enums should be inferred as object value nodes
/// </summary>
/// <example>
/// Given the following enum
/// <br/>
/// <code>
/// [Flags]
/// public enum Example { First, Second, Third }
///
/// public class Query { public Example Loopback(Example input) => input;
/// </code>
/// <br/>
/// The following schema is produced
/// <br/>
/// <code>
/// type Query {
/// loopback(input: ExampleFlagsInput!): ExampleFlags
/// }
///
/// type ExampleFlags {
/// isFirst: Boolean!
/// isSecond: Boolean!
/// isThird: Boolean!
/// }
///
/// input ExampleFlagsInput {
/// isFirst: Boolean
/// isSecond: Boolean
/// isThird: Boolean
/// }
/// </code>
/// </example>
bool EnableFlagEnums { get; }

/// <inheritdoc cref="SchemaOptions.EnableDefer"/>
/// <summary>
/// Enables the @defer directive.
/// Defer and stream both are at the moment preview features.
/// </summary>
bool EnableDefer { get; }

/// <inheritdoc cref="SchemaOptions.EnableStream"/>
/// <summary>
/// Enables the @stream directive.
/// Defer and stream both are at the moment preview features.
/// </summary>
bool EnableStream { get; }

/// <inheritdoc cref="SchemaOptions.MaxAllowedNodeBatchSize"/>
/// <summary>
/// Specifies the maximum allowed nodes that can be fetched at once through the nodes field.
/// </summary>
int MaxAllowedNodeBatchSize { get; }

/// <inheritdoc cref="SchemaOptions.StripLeadingIFromInterface"/>
/// <summary>
/// Specified if the leading I shall be stripped from the interface name.
/// </summary>
bool StripLeadingIFromInterface { get; }

/// <inheritdoc cref="SchemaOptions.EnableTrueNullability"/>
/// <summary>
/// Specifies that the true nullability proto type shall be enabled.
/// </summary>
bool EnableTrueNullability { get; }

/// <inheritdoc cref="SchemaOptions.EnableTag"/>
/// <summary>
/// Specifies that the @tag directive shall be registered with the type system.
/// </summary>
bool EnableTag { get; }
}
139 changes: 0 additions & 139 deletions src/HotChocolate/Core/src/Types/ReadOnlySchemaOptions.cs

This file was deleted.

Loading

0 comments on commit 3501daa

Please sign in to comment.