GraphQL.Annotations.TSql.AspNetCore
0.1.5
dotnet add package GraphQL.Annotations.TSql.AspNetCore --version 0.1.5
NuGet\Install-Package GraphQL.Annotations.TSql.AspNetCore -Version 0.1.5
<PackageReference Include="GraphQL.Annotations.TSql.AspNetCore" Version="0.1.5" />
<PackageVersion Include="GraphQL.Annotations.TSql.AspNetCore" Version="0.1.5" />
<PackageReference Include="GraphQL.Annotations.TSql.AspNetCore" />
paket add GraphQL.Annotations.TSql.AspNetCore --version 0.1.5
#r "nuget: GraphQL.Annotations.TSql.AspNetCore, 0.1.5"
#:package GraphQL.Annotations.TSql.AspNetCore@0.1.5
#addin nuget:?package=GraphQL.Annotations.TSql.AspNetCore&version=0.1.5
#tool nuget:?package=GraphQL.Annotations.TSql.AspNetCore&version=0.1.5
GraphQL.Annotations.TSql
C# Library for adding objects which map to TSQL Tables to a graphql schema, Intended to be used with the GraphQL package on nuget. A sample project is included with the db schema required to run it. The client side code is based on the react ui from haikyuu/graphql-todo-list
Usage
If you get confused with these instructions refer to the GraphQL.Annotations.ToDo.Example project
Setup
- Add the GraphQL.Annotations.TSql nuget package
- Create your schema, query, and mutation objects and add them to DI
- Add
IServiceProvideras a constructor parameter to both your Query and Mutation types - Add
this.AddGraphQLTSqlMutationFields<Mutation>(serviceProvider);inside the constructor of the mutation class - Add
this.AddGraphQLTSqlQueryFields<Query>(serviceProvider);inside the constructor of the query class. - Add
services.AddGraphQLTSql<Query, Mutation>();inside your Startup.ConfigureServices method - Create a class implementing
ISqlConnectionGetterand add it to DI using the interface. This class will be used to create all connections, the return value of theGetConnectionmethod will be automatically disposed - If you are using the GraphQL.Server package with Asp.Net
- Add the
GraphQL.Annotations.TSql.AspNetCorepackage - Add
.AddHttpContextUserContextBuilder()to the end of yourservices.AddGraphQLcall
- Add the
Creating objects
This library is based on the GraphQL.Annotations library and uses similar syntax
For query only objects
This is the simpler case and will only add the object to your query type
- Inherit from
SqlFieldResolver<T>filling in the class name as the type argument - Create properties and annotate them using SqlGraphQLField. Each field must be nullable otherwise you will run into
runtime errors
- You should not start any of your fields with an
_all system fields will start with one and using them will potentially result in naming conflicts
- You should not start any of your fields with an
- Implement the
Table,DefaultOrder, andPrimaryPropertypropertiesTableis the table or view that this object is bound toDefaultOrderis the property which will be used for ordering by default. Use the property name, not the sql field namePrimaryPropertyis the field which contains the primary key. Use the property name, not the sql field name. This MUST return a unique value per row, it is advised that this is also indexed
- Add the
GraphQLObjectattribute to the class
For mutable objects
These are a little more involved documentation is in the wiki
Querying objects
The documentation for querying should be in the resulting graphql schema. Some of the potential problems and things to watch out for are in the wiki
Additional features can be found in the wiki.
Releasing
All Pull Requests should be available as a prerelease on nuget.org. To create an official release create a release in github with the new version number, after the build completes it will be uploaded to nuget.org
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- GraphQL.Annotations.TSql (>= 0.1.5)
- Microsoft.AspNetCore (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|