cajuncoding / GraphQL.RepoDB

A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that encapsulate all data access (without dependency on IQueryable and execution outside of the devs control).
MIT License
40 stars 5 forks source link

How to use GraphQL.RepoDB without Azure? #6

Closed ZedZipDev closed 3 years ago

ZedZipDev commented 3 years ago

Is it possible to use GraphQL.RepoDB without Azure packages?

cajuncoding commented 3 years ago

Yes absolutely! They don’t have any dependencies between each other.

The demo project is merely using Azure Function as an example that serves multiple purposes.

The Azure Function proxy library only enables HotChocolate to run within the context of Azure Functions v2 & V3. Otherwise it has no affect on the execution pipeline, field middleware, or resolvers.

The RepoDB extensions work with the Hot Chocolate field middleware/resolvers within the execution pipeline to provide a simplified facade and ready-to-use mapping implementation directly for RepoDB micro-orm. It works with any deployment of Hot Chocolate (eg .Net Core Web App, Azure Functions, etc.).

I strongly recommend spending time to get a solid understanding of how HotChocolate v11 configuration/startup works.

ZedZipDev commented 3 years ago

Thank you, I will try to test this way. But will ask questions if have ;-)

In that case I need to use the same NuGet packages as you wrote in readme?

cajuncoding commented 3 years ago

Sure, but be sure to read the documentation provided by the HotChocolate core team and the Workshop!

The difference is that GraphQL.RepoDB makes it a lot easier to work without IQueryable or Entity Framework dependency. And it does this inside the resolver…

So anytime you would normally inject IResolverContext in HC workshop or docs, now with GraphQL.RepoDB you have another option to now inject IParamsContext which is an easier to use facade…and the library offers another helper that uses that to work more easily with RepoDB micro-orm by automatically mapping to RepoDB models, fields, sort args, etc.

All outlined in the readme examples and demo project.

If any of this isn’t clear then it will be much easier to understand once you’ve got a grasp of GraphQL & HotChocolate fundamentals :-)

ZedZipDev commented 3 years ago

Ok, thank you. So what NuGet packages should I use in my ASP.NET Server when I need only HC without EF and without Azure functionality ? Is this right minimal set:

  1. GraphQL.PreProcessingExtension
  2. GraphQL.RepoDb.SqlServer ?
cajuncoding commented 3 years ago

Yes… all you need to install is: GraphQL.RepoDB.SqlServer, it’s dependencies will automatically be installled by Nuget. Again this is also outlined in the readme here..

And you will have to install RepoDB itself…