GraphQL.Validation icon indicating copy to clipboard operation
GraphQL.Validation copied to clipboard

Improved DI and GraphQL builder support

Open mbcrawfo opened this issue 3 years ago • 2 comments

I discovered the library today, but it took a while to figure out how to set it up to work with the IGraphQLBuilder that GraphQL.Net now provides for DI setup. Once I got it working, I realized that the configuration could be wrapped in a single method working with the builder. Also, when working with DI we don't actually need a validator cache (the user registers their validators with DI, we query DI to find out what validators are available), allowing setup to be simplified even more.

Changes in this PR:

  • Add default builder configuration method that uses DI to resolve validators.
  • Add configuration overload method if the user does not want to use DI and wishes to provider an IValidatorCache.
  • Add ValidatorServiceProviderCache which doesn't actually hold a cache, it just does lookups in the service provider to see what validators are available. IMO this should deprecate ValidatorServiceCache, but I wasn't able to mark it as obsolete due to obsolete warnings being treated as errors.
  • Update readme to describe the new simplified configuration.

mbcrawfo avatar Feb 17 '23 23:02 mbcrawfo

can u add some tests for this

SimonCropp avatar May 03 '23 01:05 SimonCropp

@SimonCropp the test project fails to build because "markdownsnippets" returns errors about the readme containing invalid words "you" and "your". I've searched the documentation in this project and looked at the markdownsnippets project. It's rather confusing why a tool that (according to its readme) is for "extracting snippets from code files and merging them into markdown documents" cares about the wording of the document? That aside, I can't find anything to indicate what validation rules are being applied to the readme or what language it wants.

mbcrawfo avatar May 09 '23 17:05 mbcrawfo