Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Using Library for Middleware and UIs #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# ASP.NET Core GraphQL Example

```
> npm install
> npm run webpack
> npm start
> browse to http://localhost:3000
```
`dotnet run --project ./src/Example/Example.csproj`

Browse to http://localhost:3000/

Api: /api/graphql
GraphiQL: /graphiql
Playground: /playground

## GraphQL.StarWars

Expand Down
30 changes: 0 additions & 30 deletions package.json

This file was deleted.

5 changes: 0 additions & 5 deletions run.sh

This file was deleted.

7 changes: 1 addition & 6 deletions src/Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQL" Version="2.0.0-alpha-820" />
<PackageReference Include="GraphQL.Authorization" Version="1.0.10-alpha-10" />
<PackageReference Include="GraphQL.Server.AspNetCore.All" Version="1.0.0-beta2" />
<PackageReference Include="GraphQL.StarWars" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="public\" />
</ItemGroup>

</Project>
86 changes: 0 additions & 86 deletions src/Example/GraphQLMiddleware.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Example/GraphQLRequest.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Example/GraphQLSettings.cs

This file was deleted.

9 changes: 0 additions & 9 deletions src/Example/GraphQLUserContext.cs

This file was deleted.

9 changes: 2 additions & 7 deletions src/Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.StaticFiles;

Expand All @@ -8,13 +9,7 @@ public class Program
{
public static void Main(string[] args)
{
var directory = Directory.GetCurrentDirectory();

var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(directory)
.UseWebRoot(Path.Combine(directory, "public"))
.UseIISIntegration()
var host =WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();

Expand Down
22 changes: 6 additions & 16 deletions src/Example/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
using Microsoft.Extensions.Logging;
using System.IO;
using Microsoft.Extensions.FileProviders;
using GraphQL.Server.AspNetCore;

namespace Example
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDependencyResolver>(s => new FuncDependencyResolver(type => s.GetRequiredService(type)));

services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
services.AddSingleton<IDocumentWriter, DocumentWriter>();
services.AddResponseCompression();

services.AddSingleton<StarWarsData>();
services.AddSingleton<StarWarsQuery>();
Expand All @@ -30,9 +28,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<DroidType>();
services.AddSingleton<CharacterInterface>();
services.AddSingleton<EpisodeEnum>();
services.AddSingleton<ISchema, StarWarsSchema>();

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<StarWarsSchema>(s => new StarWarsSchema(new FuncDependencyResolver(type => (GraphType)s.GetService(type))));
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
Expand All @@ -44,16 +40,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app.UseDeveloperExceptionPage();
}

app.UseMiddleware<GraphQLMiddleware>(new GraphQLSettings
{
BuildUserContext = ctx => new GraphQLUserContext
{
User = ctx.User
}
app.UseResponseCompression();
app.UseGraphQL(new GraphQLMiddlewareSettings{
Schema=app.ApplicationServices.GetRequiredService<StarWarsSchema>()
});

app.UseDefaultFiles();
app.UseStaticFiles();
}
}
}
12 changes: 0 additions & 12 deletions src/Example/public/index.html

This file was deleted.

10 changes: 0 additions & 10 deletions src/app/app.css

This file was deleted.

16 changes: 0 additions & 16 deletions src/app/app.js

This file was deleted.

35 changes: 0 additions & 35 deletions webpack.config.js

This file was deleted.

Loading