diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a38302f..f056eb7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -45,7 +45,7 @@ jobs: curl -sSL https://rover.apollo.dev/nix/latest | sh echo "$HOME/.rover/bin" >> $GITHUB_PATH - name: Generate Schema - run: dotnet run -- schema export --output schema.graphqls + run: dotnet run --project Server -- schema export --output ../schema.graphql - name: Schema Check run: rover subgraph check ${{ secrets.APOLLO_GRAPH_REF }} --schema schema.graphqls --name ${{ env.SUBGRAPH_NAME }} env: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 47c3efa..c9a41b0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,7 +36,7 @@ jobs: publish_schema: name: Publish new schema to Apollo Studio if: false - needs: [ deploy ] + needs: [deploy] env: APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }} # rename this to a valid subgraph name @@ -54,7 +54,7 @@ jobs: curl -sSL https://rover.apollo.dev/nix/latest | sh echo "$HOME/.rover/bin" >> $GITHUB_PATH - name: Generate Schema - run: dotnet run -- schema export --output schema.graphqls + run: dotnet run --project Server -- schema export --output ../schema.graphql - name: Publish Schema run: rover subgraph publish ${{ secrets.APOLLO_GRAPH_REF }} --schema src/main/resources/graphql/schema.graphqls --name ${{ env.SUBGRAPH_NAME }} --routing-url ${{ secrets.PRODUCTION_URL }} env: diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..69f4bc2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,13 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "generate-schema", + "command": "dotnet run --project Server -- schema export --output ../schema.graphql", + "type": "shell", + "problemMatcher": "$msCompile" + } + ] +} diff --git a/README.md b/README.md index 9d8fe35..11784e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # .NET HotChocolate Federated GraphQL Subgraph -[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/MeiYeR?referralCode=neALOu) +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/asB7Lh?referralCode=neALOu) This is an example application template that can be used to create Federated GraphQL subgraph using [HotChocolate](https://chillicream.com/docs/hotchocolate/v13). You can use this template from [Rover](https://www.apollographql.com/docs/rover/commands/template/) with `rover template use --template subgraph-dotnet-hotchocolate-annotation`. diff --git a/Server/Program.cs b/Server/Program.cs index d995dec..92bc262 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -1,6 +1,7 @@ using ApolloGraphQL.HotChocolate.Federation.Two; using HotChocolate.AspNetCore; using HotChocolate.Execution; +using Microsoft.Extensions.Hosting; var builder = WebApplication.CreateBuilder(args); @@ -23,7 +24,7 @@ app.MapGraphQL(); app.MapBananaCakePop("/"); -app.Run(); +app.RunWithGraphQLCommandsAsync(args); public sealed class RouterAuthInterceptor : DefaultHttpRequestInterceptor {