JsonApiContext should be split into multiple classes for easy testability #504
Labels
breaking-change
enhancement
refactor
RFC
Request for comments. These issues have major impact on the direction of the library.
And we are mostly concerned with making sure that the deserializer has no need for the current HttpContext so that we can stop with E2E testing trivial stuff.
JsonApiContext
isscoped
With these notes we want to see the lifecycle of the
JsonApiContext
Where does Middleware touch JsonApiContext
These fields are being set by means of
JsonApiContext
:JsonApiContext.BeginOperation()
IncludedRelationships = new List<string>();
- Is populated in ApplyContext(controller)AttributesToUpdate = new Dictionary<AttrAttribute, object>();
- Populated in deserializerRelationshipsToUpdate = new Dictionary<RelationshipAttribute, object>();
- populated in deserializerHasManyRelationshipPointers = new HasManyRelationshipPointers();
- Populated in deserializerHasOneRelationshipPointers = new HasOneRelationshipPointers();
- populated in deserializerController
jsonApiContext.applyContext(this )
this = controllerQuerySet = _queryParser.Parse(context.Request.Query);
BasePath = new LinkBuilder(this).GetBasePath(context,
_controllerContext.RequestEntity.EntityName);PageManager = GetPageManager();
IsRelationshipPath = PathIsRelationship(context.Request.Path.Value);
so
JsonApiContext
field happens in the deserializer (Middleware) and controllerJsonApiContext
are used readonly (I thinkThings that need to be taken out of the deserializer
In stead of using the
JsonApiContext
itself we should use a relevant service for this, maybe even multiple, and inject them when neededJsonApiContext wordt dan eigenlijk een JsonApiContextInitializer, in de zin van dat het niet de context zelf meer is maar alleen de context populate in de set van context services.
Scoped
QueryParamFetcher
BodyInterpreter
HookExecutor
Singleton
OptionsFetcher
GenericProcessorFactory
The text was updated successfully, but these errors were encountered: