public CoreQuery(TempDBContext database) { Field <ListGraphType <OrganisationType> >( "organisations", resolve: context => database.Organisations() ); Field <OrganisationType>( "organisation", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = new Guid(context.GetArgument <string>("id")); return(database.Organisations()); }); Field <ListGraphType <EmployerType> >( "employers", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "organisationId" }), resolve: context => { var id = new Guid(context.GetArgument <string>("organisationId")); return(database.Employers().Where(x => x.OrganisationId == id)); }); }
public CoreMutation(TempDBContext database, EmployerMessagingService employerMessageService) { FieldAsync <EmployerType>( "createEmployer", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <EmployerInputType> > { Name = "employer" }), resolve: async context => { var employer = context.GetArgument <Employer>("employer"); database.Employers().Add(employer); employerMessageService.AddEmployerAddedMessage(employer); return(employer); }); }