Skip to content

clientConfigBuilder.build(wrapperCache, resolver) should accept a Resolver OR WrapperCache, not both #1507

@pileks

Description

@pileks

Describe the bug
As the title describes, the clientConfigBuilder.build(wrapperCache, resolver) method should accept a Resolver OR WrapperCache, not both.
The reason for this is the method is opaque to outside developers, and it's unclear what it does with these two arguments.
Essentially, the build method will only use the wrapperCache parameter if a resolver parameter is not provided, otherwise it will use the resolver parameter or build a completely new Resolver for the CoreClientConfig.

Expected behavior
This, in my view, is a bug, and can be easily mitigated by having the build method accept a single argument of type:

type BuildOptions = { resolver: IUriResolver<unknown> } | { wrapperCache: IWrapperCache };

This would make sure that developers are explicit in their intent, and that the build method behaves in accordance with the developer's intent.
Having a BuildOptions type instead of something simple like an IUriResolver | IWrapperCache is a preference, but it will allow us to add additional options in the future (maybe even for both cases) while not breaking the method signature.

Additional context
Found while working on the #1480 refactor.

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions