Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 2nd, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // MyDataGraphType.cs
  2. public class MyDataGraphType : InterfaceType<MyData>
  3. {
  4.     protected override void Configure(IInterfaceTypeDescriptor<MyData> descriptor)
  5.     {
  6.         descriptor.Name("MyData");
  7.  
  8.         descriptor.Field(f => f.Id).Type<NonNullType<IdType>>();
  9.         descriptor.Field(f => f.Name).Type<StringType>();
  10.     }
  11. }
  12.  
  13. // FooType.cs
  14. public class FooType : ObjectType<Foo>
  15. {
  16.     protected override void Configure(IObjectTypeDescriptor<Foo> descriptor)
  17.     {
  18.         descriptor.Interface<MyDataGraphType>();
  19.  
  20.         descriptor.Field(f => f.FooTime).Type<DateTimeType>();
  21.     }
  22. }
  23.  
  24. // BarType.cs
  25. public class BarType : ObjectType<Bar>
  26. {
  27.     protected override void Configure(IObjectTypeDescriptor<Bar> descriptor)
  28.     {
  29.         descriptor.Interface<MyDataGraphType>();
  30.     }
  31. }
  32.  
  33. // Query.cs
  34. public class Query
  35. {
  36.     private readonly IMyDataProvider provider;
  37.     public Query(IMyDataProvider provider)
  38.     {
  39.         this.provider = provider ?? throw new ArgumentNullException(nameof(provider));
  40.     }
  41.  
  42.     public IEnumerable<MyData> ReadAllData(MyDataType dataType)
  43.     {
  44.         return this.provider.ReadAllData(dataType);
  45.     }
  46. }
  47.  
  48. // QueryType.cs
  49. public class QueryType : ObjectType<Query>
  50. {
  51.     protected override void Configure(IObjectTypeDescriptor<Query> descriptor)
  52.     {
  53.     descriptor.Field(f => f.ReadAllData(default))
  54.         .Type<ListType<MyData>>()
  55.         .Argument("dataType", a => a.DefaultValue(MyDataType.None));
  56.     }
  57. }
  58.  
  59. // Startup.cs
  60.     services.AddTransient<IMyDataProvider, DummyDataProvider>();
  61.     services.AddGraphQL(sp => SchemaBuilder.New()
  62.         .AddServices(sp)
  63.         .AddQueryType<QueryType>()
  64.         .AddType<FooType>()
  65.         .Create());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top