public ChatResolvers(IChatResolverService resolverService) { this["Query"] = new FieldResolversMap { { "messages", resolverService.GetMessagesAsync } }; this["Mutation"] = new FieldResolversMap { { "addMessage", resolverService.AddMessageAsync }, { "editMessage", resolverService.EditMessageAsync } }; this["Subscription"] = new FieldResolversMap { { "messages", resolverService.StreamMessagesAsync, resolverService.ResolveMessageAsync } }; this["Message"] = new FieldResolversMap { { "id", PropertyOf <Message>(m => m.Id) }, { "from", PropertyOf <Message>(m => m.From) }, { "content", PropertyOf <Message>(m => m.Content) }, { "timestamp", PropertyOf <Message>(m => m.Timestamp) } }; this["From"] = new FieldResolversMap { { "userId", PropertyOf <From>(f => f.UserId) }, { "name", PropertyOf <From>(f => f.Name) } }; }
public IntrospectionResolvers(string queryTypeName = "Query") { this[queryTypeName] = new FieldResolversMap { { "__schema", context => ResolveSync.As(context.Schema) }, { "__type", context => ResolveSync.As(context.Schema.GetNamedType(context.GetArgument <string>("name"))) } }; this[IntrospectionSchema.SchemaName] = new FieldResolversMap { { "types", context => ResolveSync.As(context.Schema .QueryTypes <TypeDefinition>(IsNotBuiltIn) .OrderBy(t => t.Name.Value)) }, { "queryType", context => ResolveSync.As(context.Schema.Query) }, { "mutationType", context => ResolveSync.As(context.Schema.Mutation) }, { "subscriptionType", context => ResolveSync.As(context.Schema.Subscription) }, { "directives", context => ResolveSync.As(context.Schema.QueryDirectiveTypes().OrderBy(t => t.Name.Value)) } }; this[IntrospectionSchema.TypeName] = new FieldResolversMap { { "kind", Resolve.PropertyOf <INode>((t, context) => KindOf(context.Schema, t)) },