-
Notifications
You must be signed in to change notification settings - Fork 11
Minimal API Support (v2.0) #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also: * decoupled directive resolver methods from templates * removed non-schema arguments from the schema data (only exists in resovler meta data)
Moved unit tests according to new schema/typeTemplates folder structure
Also fixed new minimal api unit tests to target NSubstitute
graphql-aspnet-owner
approved these changes
Nov 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minimal Api Support
Added support for "minimal api" style fields for
query
,mutation
andsubscription
operations.Highlights:
FieldResolutionContext
,DirectiveResolutionContext
, andHttpContext
for advanced metadata such as the active user, the current field being resolved etc.Major Updates
[FromServices]
attribute. You can now inject services directly into a controller or minimal api method.SourceArgument
from the schema.ISchema
is now a "pure" representation of the runtime graphql schema.IGraphField.Resolver
property.Int
,Float
,Bool
,String
,ID
) remain constant and cannot be redeclared with different implementations.Minor Updates
[Union]
to enhance the readability of defining a union on a field.Breaking Changes
Minor Breaking Changes
These changes may effect you if you've done signifcant customization of the templating and schema generation process.
FieldResolutionContext
andDirectiveResolutionContext
to remove dependencies on middleware contexts, constructor arguments have changed as a result.GraphQLProviders
service locator class. All functionality has been ecapsulated to a "per schema" service injectionIGraphQLSchemaFactory<TSchema>
.IScalarGraphType.Clone()
, used by the runtime to create "per schema" instances of a scalar class with alternative or different type naming.ISchemaExtension
intoIGraphQLServerExtension
. A custom extension need only declare the methods it wishes to implement to subscribe to those registration and setup calls.SchemaOptions.AddConfigurationExtension
to.AddSchemaExtension
to better clarify intentIGraphTypeTemplateProvider.ParseType(IGraphQLRuntimeSchemaItemDefinition)
to support the templatizing of minimal api fields.IScalarGraphType.OtherTypes
. Each scalar is now locked 1:1 with a a single .NET type. All inferences or requirements ofNullable<T>
are handled automatically by the runtime.Quality of Life Improvements
FieldResolutionContext
,DirectiveResolutionContext
andHttpContext
as injectable parameters to all field resolvers.IGraphSchemaFactory<TSchema>
used to build out a schema instance at start up. The default implementation can be swapped out per schema to better facilitate custom implementations.Bug Fixes
[GraphSkip]
would not be honored for some method parameter types. An exception will now be thrown if an argument to a field is declared with a type that has the Graph Skip attribute applied.InternalName
ofGraphArgument
was being incorrectly set to the full internal name of the parameter on which the argument is based.ActionMethodModelStateValidatedLogEntr
y was printing the return type of an action method instead of the name of the controller that owns it for the controller name property.[Query]
,[Mutation]`` and
[Subscription]` that would cause null argument exceptions in some union definitions use cases.RouteNotFoundActionResult
not propagating a captured exception in some scenarios. Any captured exception will now be correctly nested as an inner exception or as a top level exception depending on the route failure type..AllSchemaItems()
)Namespace Reorganizations
Internal.Templates
toSchema.Generation.TypeTemplates
Internal.Resolvers
toExecution.Resolvers
Execution.TypeMakers
toSchema.Generation.TypeMakers
TestServer Changes
CreateGraphTypeFieldContextBuilder()
andCreateActionMethodFieldContextBuilder()
. Added appropriate overloads ofCreateFieldContextBuilder()
to simplify the interface.CreateFieldExecutionContext()
it now exists as part ofFieldContextBuilder
Mock<T>
poweringFieldContextBuilder.FieldRequest
instance to allow consumers to update or change the mocked values for various testing scenarios. Users of this object may need to applyFieldRequest.Object
at locations where they have used.FieldRequest
in the past.Detailed ChangeLog
IGraphMethod
, used by the baseGraphController
and formalized a newISchemaItemResolverMetaData
interface to encapsulate all resolver related data for any field or directive in the system.ExecutionArgumentCollection
object to work off the resolution contexts (FieldResolutionContext
,DirectiveResolutionContext
) instead of their middleware counterparts.IGraphArgumentCollection.SourceArgument
. Its now handled by the resolver by and not part of the schema.MethodGraphField
must supply adeclaredReturnType
during its constructor. It will no longer try to infer a valid return type from the supplied resolver.MethodGraphField
must supply aobjectType
during its constructor. It will no longer try to infer a valid return type from the supplied resolver.IGraphFieldResolverMethod
toIGraphFieldResolverMetaData
and decoupled it from any graphql dependent objects. This object now represents ONLY data related to the invocation of a C# method or property.IGraphField
not correctly implementsITypedSchemaItem
Internal
on theGraphArgumentModifiers
enumeration. UseEnum.IsPartOftheSchema()
andIsNotPartOfTheSchema()
instead to determine the nature of the a parameter's location.ISchemaItem.InternalName
. All schema items are now referrred to by a singular internal name that defaults to the full name of the entity (e.g.MyObject.MyMethod
). A new optional property has been added to all graph attributes to allow the setting of a customInternalName
to use in log entries and exception methods (e.g.[Query(InternalName = "MyCustomName")]
).ISchemaItem.InternalFullName
has been eliminatedIEnumValue.InternalValue
toDeclaredValue
to separate its intent fromInternalName
. This property is readonly.IEnumValue.DeclaredLabel
to separate the required, code-defined label from the developer's customizableInternalName
GraphFieldTemplate.PossibleTypes
toPossibleObjectTypes
to better clarify the intent of the contained items.options
parameter from.AddSubscriptionPublishing()
, it was not being used.IServiceProviders
per service instance if the option is ever needed.IServiceCollection
to be anInvalidOprationException
to help with clarity (formallyGraphTypeDeclarationException
).IGraphArgument.ArgumentModifiers
. ArgumentModifiers are now part of the resolver parameters and not part of the generatedISchema
.PropertyGraphField
class. All fields are (property and method based) are now implemented viaMethodGraphField
.Normalized
IUnionGraphTypeMaker
its no long a "special case" usage of a type maker.