Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public interface IReadOnlyTypeDefinitionCollection : IReadOnlyList<ITypeDefiniti
/// Tries to get a type by its name and kind.
/// </summary>
/// <param name="name">The name of the type.</param>
/// <param name="type">The resolved type.</param>
/// <param name="typeDefinition">The resolved type.</param>
/// <returns>
/// <c>true</c>, if a type with the name exists and is of the specified
/// kind, <c>false</c> otherwise.
/// </returns>
bool TryGetType(string name, [NotNullWhen(true)] out ITypeDefinition? type);
bool TryGetType(string name, [NotNullWhen(true)] out ITypeDefinition? typeDefinition);

/// <summary>
/// Tries to get a type by its name and kind.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ protected internal override void TryConfigure(
unionTypeDescriptor.Inaccessible();
break;

case IScalarTypeDescriptor scalarTypeDescriptor:
scalarTypeDescriptor.Inaccessible();
break;

default:
throw new NotSupportedException(
$"The {descriptor.GetType().Name} descriptor is not supported.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,35 @@ public static IUnionTypeDescriptor Inaccessible(
ArgumentNullException.ThrowIfNull(descriptor);
return descriptor.Directive(Composite.Inaccessible.Instance);
}

/// <summary>
/// <para>
/// Applies the @inaccessible directive to the scalar type to prevent it
/// from being accessible through the client-facing composite schema,
/// even if it is accessible in the underlying source schemas.
/// </para>
/// <para>
/// <code language="graphql">
/// scalar Email @inaccessible
/// </code>
/// </para>
/// <para>
/// <see href="https://graphql.github.io/composite-schemas-spec/draft/#sec--inaccessible"/>
/// </para>
/// </summary>
/// <param name="descriptor">
/// The union type descriptor to apply the directive to.
/// </param>
/// <returns>
/// The union type descriptor with the directive applied.
/// </returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="descriptor"/> is <c>null</c>.
/// </exception>
public static IScalarTypeDescriptor Inaccessible(
this IScalarTypeDescriptor descriptor)
{
ArgumentNullException.ThrowIfNull(descriptor);
return descriptor.Directive(Composite.Inaccessible.Instance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ public T GetType<T>(string name)
/// Tries to get a type by its name and kind.
/// </summary>
/// <param name="name">The name of the type.</param>
/// <param name="type">The resolved type.</param>
/// <param name="typeDefinition">The resolved type.</param>
/// <returns>
/// <c>true</c>, if a type with the name exists and is of the specified
/// kind, <c>false</c> otherwise.
/// </returns>
public bool TryGetType(string name, [NotNullWhen(true)] out ITypeDefinition? type)
public bool TryGetType(string name, [NotNullWhen(true)] out ITypeDefinition? typeDefinition)
{
if (_typeLookup.TryGetValue(name, out var t))
{
type = t;
typeDefinition = t;
return true;
}

type = null;
typeDefinition = null;
return false;
}

Expand Down
Loading
Loading