dlukez - GraphQL.Annotations 1.0.4

Attribute-based schema definitions for GraphQL in .NET

PM> Install-Package GraphQL.Annotations -Version 1.0.4 -Source https://www.myget.org/F/dlukez/api/v3/index.json

Copy to clipboard

> nuget.exe install GraphQL.Annotations -Version 1.0.4 -Source https://www.myget.org/F/dlukez/api/v3/index.json

Copy to clipboard

> dotnet add package GraphQL.Annotations --version 1.0.4 --source https://www.myget.org/F/dlukez/api/v3/index.json

Copy to clipboard
<PackageReference Include="GraphQL.Annotations" Version="1.0.4" />
Copy to clipboard
source https://www.myget.org/F/dlukez/api/v3/index.json

nuget GraphQL.Annotations  ~> 1.0.4
Copy to clipboard

> choco install GraphQL.Annotations --version 1.0.4 --source https://www.myget.org/F/dlukez/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "dlukez" -SourceLocation "https://www.myget.org/F/dlukez/api/v2"
Install-Module -Name "GraphQL.Annotations" -RequiredVersion "1.0.4" -Repository "dlukez" 
Copy to clipboard

GraphQL.Annotations

NuGet MyGet Pre Release MyGet Build Status

Attribute-based schema definitions for GraphQL in .NET.

Have a look through the sample app and leave some feedback.

Running the sample app

cd samples/GraphQL.Annotations.StarWarsApp/
dotnet build
dotnet ef database update
dotnet run

Annotating your models

Full example

// Model/QueryRoot.cs

[GraphQLObject]
public class QueryRoot : IDisposable
{
    public StarWarsContext Db = new StarWarsContext();

    [GraphQLFunc]
    public IEnumerable<Droid> Droids(ResolveFieldContext context)
    {
        var db = context.GetDataContext();
        return db.Droids.ToList();
    }

    [GraphQLFunc]
    public IEnumerable<Human> Humans(ResolveFieldContext context)
    {
        var db = context.GetDataContext();
        return db.Humans.ToList();
    }

    public void Dispose()
    {
        Db.Dispose();
    }
}

// Model/Droid.cs

[GraphQLObject]
public class Droid : ICharacter
{
    [GraphQLField]
    public int DroidId { get; set; }

    [GraphQLField]
    public string Name { get; set; }

    [GraphQLField]
    public string PrimaryFunction { get; set; }

    [GraphQLFunc]
    public IEnumerable<ICharacter> Friends(ResolveFieldContext context)
    {
        var db = context.GetDataContext();
        return db.Friendships
            .Where(f => f.DroidId == ((Droid)context.Source).DroidId)
            .Select(f => f.Human);
    }
}

Todo

  • Include Scalar example.
  • Fill out this readme.
  • .NETFramework 4.5
    • GraphQL (>= 0.14.6.657)
  • .NETStandard 1.1
    • GraphQL (>= 0.14.6.657)
    • NETStandard.Library (>= 1.6.0)
    • System.ComponentModel.TypeConverter (>= 4.3.0)
  • .NETFramework 4.5: 4.5.0.0
  • .NETStandard 1.1: 1.1.0.0

Owners

Daniel

Authors

Daniel Zimmermann

Project URL

https://github.com/dlukez/graphql-dotnet-annotations

License

MIT

Tags

graphql conventions annotations attributes schema generation

Info

579 total downloads
47 downloads for version 1.0.4
Download (27.61 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.6-ci0001 29.66 KB Mon, 10 Apr 2017 17:08:30 GMT 47
1.0.5 29.65 KB Mon, 10 Apr 2017 16:54:41 GMT 49
1.0.5-ci0004 29.66 KB Wed, 22 Mar 2017 08:00:58 GMT 46
1.0.5-ci0003 27.62 KB Mon, 20 Feb 2017 02:01:35 GMT 45
1.0.4 27.61 KB Sun, 19 Feb 2017 18:28:14 GMT 47
1.0.4-ci0001 27.62 KB Sat, 18 Feb 2017 05:12:25 GMT 43
1.0.3 14.84 KB Fri, 17 Feb 2017 02:15:17 GMT 46
1.0.3-ci0001 14.85 KB Fri, 17 Feb 2017 02:07:41 GMT 45
1.0.2 14.84 KB Thu, 16 Feb 2017 21:07:05 GMT 47
1.0.2-ci0003 14.85 KB Thu, 16 Feb 2017 20:56:43 GMT 34
1.0.2-ci.1 10.46 KB Mon, 13 Feb 2017 04:06:58 GMT 41
1.0.1 10.45 KB Sun, 12 Feb 2017 23:48:48 GMT 48
1.0.0 10.46 KB Sun, 12 Feb 2017 10:15:52 GMT 41