LoginSignup
0
0

More than 5 years have passed since last update.

ASP.NET > GraphQL

Posted at

NuGetの追加 → GraphQL

image

graphql-dotnet/examples

startup.cs

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{

    services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
    var sp = services.BuildServiceProvider();
    services.AddSingleton<ISchema>(new VivaSchema(new FuncDependencyResolver(type => sp.GetService(type))));
}

Models

Sckema

using GraphQL;
using GraphQL.Types;

namespace NHLStats.Api.Models
{
    public class NHLStatsSchema : Schema
    {
        public NHLStatsSchema(IDependencyResolver resolver): base(resolver)
        {
            Query = resolver.Resolve<NHLStatsQuery>();
            Mutation = resolver.Resolve<NHLStatsMutation>();
        }
    }
}

Query

Mutation

IPlayerRepository

PlayerType

query NHLStatsQuery($id: Int!){
  player(id: $id){
    id
  }
}

PlayerRepository

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0