From 6f73dfe360c86e897e4531eb5f410bdc6a747911 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Mon, 18 Nov 2024 10:23:00 +0100 Subject: [PATCH] Use GraphQL 8.2.1 (#1211) --- src/WireMock.Net/Matchers/GraphQLMatcher.cs | 10 ++--- src/WireMock.Net/WireMock.Net.csproj | 3 +- .../Matchers/GraphQLMatcherTests.cs | 42 ++++++++++++------- .../WireMock.Net.Tests.csproj | 1 - 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/WireMock.Net/Matchers/GraphQLMatcher.cs b/src/WireMock.Net/Matchers/GraphQLMatcher.cs index 305b973e..2227b371 100644 --- a/src/WireMock.Net/Matchers/GraphQLMatcher.cs +++ b/src/WireMock.Net/Matchers/GraphQLMatcher.cs @@ -113,16 +113,16 @@ public MatchResult IsMatch(string? input) { try { - var executionResult = new DocumentExecuter().ExecuteAsync(_ => + var executionResult = new DocumentExecuter().ExecuteAsync(eo => { - _.ThrowOnUnhandledException = true; + eo.ThrowOnUnhandledException = true; - _.Schema = _schema; - _.Query = graphQLRequest.Query; + eo.Schema = _schema; + eo.Query = graphQLRequest.Query; if (graphQLRequest.Variables != null) { - _.Variables = new Inputs(graphQLRequest.Variables); + eo.Variables = new Inputs(graphQLRequest.Variables); } }).GetAwaiter().GetResult(); diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index a55ee930..17711cbc 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -144,8 +144,7 @@ - - + diff --git a/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs b/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs index ac1ddfb3..1091c957 100644 --- a/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs +++ b/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs @@ -107,22 +107,32 @@ public void GraphQLMatcher_For_ValidSchema_And_CorrectGraphQL_Mutation_IsMatch() public void GraphQLMatcher_For_ValidSchema_And_CorrectGraphQL_UsingCustomType_Mutation_IsMatch() { // Arrange - const string testSchema = @" - scalar DateTime - scalar MyCustomScalar - - type Message { - id: ID! - } - - type Mutation { - createMessage(x: MyCustomScalar, dt: DateTime): Message - }"; - - var input = @"{ - ""query"": ""mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }"", - ""variables"": { ""x"": 100, ""dt"": ""2007-12-03T10:15:30Z"" } -}"; + // Query is provided here: https://stackoverflow.com/questions/59608833/apollo-graphql-error-query-root-type-must-be-provided + const string testSchema = + """ + scalar DateTime + scalar MyCustomScalar + + type Query { + _empty: String + } + + type Message { + id: ID! + } + + type Mutation { + createMessage(x: MyCustomScalar, dt: DateTime): Message + } + """; + + const string input = + """ + { + "query": "mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }", + "variables": { "x": 100, "dt": "2007-12-03T10:15:30Z" } + } + """; var customScalars = new Dictionary { { "MyCustomScalar", typeof(int) } }; diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 9f7f78e4..2468b7e4 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -105,7 +105,6 @@ -