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" />
paket add GraphQL.Annotations.TSql.AspNetCore --version 0.1.5
#r "nuget: GraphQL.Annotations.TSql.AspNetCore, 0.1.5"
// Install GraphQL.Annotations.TSql.AspNetCore as a Cake Addin
#addin nuget:?package=GraphQL.Annotations.TSql.AspNetCore&version=0.1.5
// Install GraphQL.Annotations.TSql.AspNetCore as a Cake Tool
#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
IServiceProvider
as 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
ISqlConnectionGetter
and add it to DI using the interface. This class will be used to create all connections, the return value of theGetConnection
method will be automatically disposed - If you are using the GraphQL.Server package with Asp.Net
- Add the
GraphQL.Annotations.TSql.AspNetCore
package - Add
.AddHttpContextUserContextBuilder()
to the end of yourservices.AddGraphQL
call
- 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
, andPrimaryProperty
propertiesTable
is the table or view that this object is bound toDefaultOrder
is the property which will be used for ordering by default. Use the property name, not the sql field namePrimaryProperty
is 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
GraphQLObject
attribute 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. |
.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 |
---|