diff --git a/src/Core/Abstractions/ErrorBuilderExtensions.cs b/src/Core/Abstractions/ErrorBuilderExtensions.cs
index d63614ab466..d9839ce4774 100644
--- a/src/Core/Abstractions/ErrorBuilderExtensions.cs
+++ b/src/Core/Abstractions/ErrorBuilderExtensions.cs
@@ -1,3 +1,4 @@
+using System.Globalization;
using System;
using HotChocolate.Language;
@@ -27,5 +28,14 @@ public static IErrorBuilder AddLocation(
}
return builder;
}
+
+ public static IErrorBuilder SetMessage(
+ this IErrorBuilder builder,
+ string format,
+ params object[] args) =>
+ builder.SetMessage(string.Format(
+ CultureInfo.InvariantCulture,
+ format,
+ args));
}
}
diff --git a/src/Core/Abstractions/Execution/IVariableValueCollection.cs b/src/Core/Abstractions/Execution/IVariableValueCollection.cs
index 9ade2573c2b..72e328cdbbf 100644
--- a/src/Core/Abstractions/Execution/IVariableValueCollection.cs
+++ b/src/Core/Abstractions/Execution/IVariableValueCollection.cs
@@ -6,7 +6,7 @@
public interface IVariableValueCollection
{
///
- /// Gets a coreced variable value from the collection.
+ /// Gets a coerced variable value from the collection.
///
/// The variable name.
///
@@ -22,7 +22,7 @@ public interface IVariableValueCollection
T GetVariable(NameString name);
///
- /// Tries to get a coreced variable value from the collection.
+ /// Tries to get a coerced variable value from the collection.
///
/// The variable name.
/// The coerced variable value.
diff --git a/src/Core/Core.sln b/src/Core/Core.sln
index 9b91ff8bc35..9e90018dc7b 100644
--- a/src/Core/Core.sln
+++ b/src/Core/Core.sln
@@ -41,13 +41,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Types.Filters.Tests", "Type
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Types.Tests.Documentation", "Types.Tests.Documentation\Types.Tests.Documentation.csproj", "{38537BB2-BDD9-4842-BD2D-0B84B371F1D8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersistedQueries.FileSystem", "PersistedQueries.FileSystem\PersistedQueries.FileSystem.csproj", "{BC4DAE10-B145-4F9F-9504-BF5EA4C42A60}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistedQueries.FileSystem", "PersistedQueries.FileSystem\PersistedQueries.FileSystem.csproj", "{BC4DAE10-B145-4F9F-9504-BF5EA4C42A60}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subscriptions.Redis", "Subscriptions.Redis\Subscriptions.Redis.csproj", "{85660981-4992-49A8-A786-D6FB82E01463}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Subscriptions.Redis", "Subscriptions.Redis\Subscriptions.Redis.csproj", "{85660981-4992-49A8-A786-D6FB82E01463}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarWars", "StarWars\StarWars.csproj", "{6D66B162-D2F6-411E-8F9C-F0B3AB5A9289}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarWars", "StarWars\StarWars.csproj", "{6D66B162-D2F6-411E-8F9C-F0B3AB5A9289}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersistedQueries.Redis", "PersistedQueries.Redis\PersistedQueries.Redis.csproj", "{B4CC72E4-C93E-4AFB-8381-BFF6F4B06CC9}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistedQueries.Redis", "PersistedQueries.Redis\PersistedQueries.Redis.csproj", "{B4CC72E4-C93E-4AFB-8381-BFF6F4B06CC9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistedQueries.FileSystem.Tests", "PersistedQueries.FileSystem.Tests\PersistedQueries.FileSystem.Tests.csproj", "{F3657CF0-6B18-4021-8CCF-A7C131E4F745}"
EndProject
@@ -63,9 +63,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenDonut", "..\DataLoader
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Types.Sorting", "Types.Sorting\Types.Sorting.csproj", "{F3B8AE0B-C6D9-4B45-8131-40E93CFE6BB3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Types.Sorting.Tests", "Types.Sorting.Tests\Types.Sorting.Tests.csproj", "{A23C8758-6173-46F8-B132-28E5B75846B0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Types.Sorting.Tests", "Types.Sorting.Tests\Types.Sorting.Tests.csproj", "{A23C8758-6173-46F8-B132-28E5B75846B0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Types.Sorting.Mongo.Tests", "Types.Sorting.Mongo.Tests\Types.Sorting.Mongo.Tests.csproj", "{E8843255-77EB-471F-B682-528BB4B5D1D5}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Types.Sorting.Mongo.Tests", "Types.Sorting.Mongo.Tests\Types.Sorting.Mongo.Tests.csproj", "{E8843255-77EB-471F-B682-528BB4B5D1D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/src/Core/Core/Execution/Extensions/QueryExecutionBuilderExtensions.cs b/src/Core/Core/Execution/Extensions/QueryExecutionBuilderExtensions.cs
index 602d4230b1b..6ae98f99b4b 100644
--- a/src/Core/Core/Execution/Extensions/QueryExecutionBuilderExtensions.cs
+++ b/src/Core/Core/Execution/Extensions/QueryExecutionBuilderExtensions.cs
@@ -22,8 +22,7 @@ public static IQueryExecutionBuilder UseDefaultPipeline(
throw new ArgumentNullException(nameof(builder));
}
- return builder
- .UseDefaultPipeline(new QueryExecutionOptions());
+ return builder.UseDefaultPipeline(new QueryExecutionOptions());
}
public static IQueryExecutionBuilder UseDefaultPipeline(
@@ -119,7 +118,7 @@ public static IQueryExecutionBuilder UseActivePersistedQueryPipeline(
.UseWritePersistedQuery();
}
- private static IQueryExecutionBuilder AddDefaultServices(
+ public static IQueryExecutionBuilder AddDefaultServices(
this IQueryExecutionBuilder builder,
IQueryExecutionOptionsAccessor options)
{
@@ -134,7 +133,7 @@ private static IQueryExecutionBuilder AddDefaultServices(
.AddDefaultDocumentHashProvider();
}
- private static IQueryExecutionBuilder UseDefaultDiagnostics(
+ public static IQueryExecutionBuilder UseDefaultDiagnostics(
this IQueryExecutionBuilder builder,
IInstrumentationOptionsAccessor options)
{
diff --git a/src/Core/Core/Execution/Utilities/DictionaryToObjectValueConverter.cs b/src/Core/Core/Execution/Utilities/DictionaryToObjectValueConverter.cs
index 8eb328feb3c..1e21c04612d 100644
--- a/src/Core/Core/Execution/Utilities/DictionaryToObjectValueConverter.cs
+++ b/src/Core/Core/Execution/Utilities/DictionaryToObjectValueConverter.cs
@@ -13,11 +13,6 @@ internal class DictionaryToObjectValueConverter
{
public IValueNode Convert(object from, IInputType type, VariableDefinitionNode variable)
{
- if (from == null)
- {
- throw new ArgumentNullException(nameof(from));
- }
-
if (type is null)
{
throw new ArgumentNullException(nameof(type));
@@ -35,7 +30,28 @@ public IValueNode Convert(object from, IInputType type, VariableDefinitionNode v
Name = "$" + variable.Variable.Name.Value
};
Visit(from, context);
- return (IValueNode)context.Object;
+ return from is null ? NullValueNode.Default : (IValueNode)context.Object;
+ }
+
+ public IValueNode Convert(object from, IInputType type, string variableName)
+ {
+ if (type is null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
+ if (variableName is null)
+ {
+ throw new ArgumentNullException(nameof(variableName));
+ }
+
+ var context = new ConverterContext
+ {
+ InputType = type,
+ Name = "$" + variableName
+ };
+ Visit(from, context);
+ return from is null ? NullValueNode.Default : (IValueNode)context.Object;
}
protected override void VisitObject(
diff --git a/src/Core/Core/Execution/Utilities/VariableValueBuilder.cs b/src/Core/Core/Execution/Utilities/VariableValueBuilder.cs
index 6bb09360771..471f1ad5ed0 100644
--- a/src/Core/Core/Execution/Utilities/VariableValueBuilder.cs
+++ b/src/Core/Core/Execution/Utilities/VariableValueBuilder.cs
@@ -98,8 +98,7 @@ private Variable CoerceVariableValue(
IReadOnlyDictionary variableValues,
Variable variable)
{
- var value = variableValues.TryGetValue(
- variable.Name, out var rawValue)
+ var value = variableValues.TryGetValue(variable.Name, out var rawValue)
? Normalize(variableDefinition, variable, rawValue)
: variable.DefaultValue;
@@ -197,14 +196,9 @@ private static void CheckForInvalidValueType(
if (variable.Value != null)
{
- if (variable.Value is IValueNode literal)
- {
- invalid = !variable.Type.IsInstanceOfType(literal);
- }
- else
- {
- invalid = !variable.Type.IsInstanceOfType(variable.Value);
- }
+ invalid = variable.Value is IValueNode literal
+ ? !variable.Type.IsInstanceOfType(literal)
+ : !variable.Type.IsInstanceOfType(variable.Value);
}
if (invalid)
@@ -255,8 +249,7 @@ private IType GetType(ITypeNode typeNode)
return _schema.GetType(namedType.Name.Value);
}
- throw new NotSupportedException(
- TypeResources.VariableValueBuilder_NodeKind);
+ throw new NotSupportedException(TypeResources.VariableValueBuilder_NodeKind);
}
private ref struct Variable
diff --git a/src/Core/Core/Properties/InternalsVisibleTo.cs b/src/Core/Core/Properties/InternalsVisibleTo.cs
index edd3026a15e..64a008a6546 100644
--- a/src/Core/Core/Properties/InternalsVisibleTo.cs
+++ b/src/Core/Core/Properties/InternalsVisibleTo.cs
@@ -3,3 +3,6 @@
[assembly: InternalsVisibleTo("HotChocolate.Core.Tests")]
[assembly: InternalsVisibleTo("HotChocolate.Validation.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
+
+// this is temporary until we reworked the variable coercion #1274
+[assembly: InternalsVisibleTo("HotChocolate.Stitching")]
diff --git a/src/Core/Language/Parser/GraphQLConstants.cs b/src/Core/Language/Parser/GraphQLConstants.cs
index 3d708056f5c..d8d1afe139f 100644
--- a/src/Core/Language/Parser/GraphQLConstants.cs
+++ b/src/Core/Language/Parser/GraphQLConstants.cs
@@ -5,7 +5,7 @@ namespace HotChocolate.Language
///
/// This class provides internal char utilities
/// that are used to tokenize a GraphQL source text.
- /// These utilities are used by the lexer dfault implementation.
+ /// These utilities are used by the lexer default implementation.
///
internal static partial class GraphQLConstants
{
diff --git a/src/Core/Utilities/BufferHelper.cs b/src/Core/Utilities/BufferHelper.cs
index c2e47e004c0..a75da4de492 100644
--- a/src/Core/Utilities/BufferHelper.cs
+++ b/src/Core/Utilities/BufferHelper.cs
@@ -31,8 +31,7 @@ public static async Task ReadAsync(
if (bytesRemaining == 0)
{
- var next = ArrayPool.Shared.Rent(
- buffer.Length * 2);
+ var next = ArrayPool.Shared.Rent(buffer.Length * 2);
Buffer.BlockCopy(buffer, 0, next, 0, buffer.Length);
ArrayPool.Shared.Return(buffer);
buffer = next;
diff --git a/src/Server/Server.sln b/src/Server/Server.sln
index ee311e07e43..22f1c5b14df 100644
--- a/src/Server/Server.sln
+++ b/src/Server/Server.sln
@@ -59,7 +59,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.Abstractions", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.Tests.Utilities", "AspNetCore.Tests.Utilities\AspNetCore.Tests.Utilities.csproj", "{AF440449-DBE1-40AB-B155-87C3B31E7378}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarWars", "..\Core\StarWars\StarWars.csproj", "{9CA71125-2837-4F92-9822-CB41B64E2E43}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarWars", "..\Core\StarWars\StarWars.csproj", "{9CA71125-2837-4F92-9822-CB41B64E2E43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetClassic.Abstractions", "AspNetClassic.Abstractions\AspNetClassic.Abstractions.csproj", "{B930D413-E013-4DE6-B1AB-C88BE946E615}"
EndProject
diff --git a/src/Stitching/.vscode/tasks.json b/src/Stitching/.vscode/tasks.json
new file mode 100644
index 00000000000..31c32bd3457
--- /dev/null
+++ b/src/Stitching/.vscode/tasks.json
@@ -0,0 +1,24 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "shell",
+ "args": [
+ "build",
+ // Ask dotnet build to generate full paths for file names.
+ "/property:GenerateFullPaths=true",
+ // Do not generate summary otherwise it leads to duplicate errors in Problems panel
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "group": "build",
+ "presentation": {
+ "reveal": "silent"
+ },
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/Stitching/Stitching.Tests/Client/__snapshots__/RemoteQueryClientTests.DispatchMultipleQueriesWithVariables.snap b/src/Stitching/Stitching.Tests/Client/__snapshots__/RemoteQueryClientTests.DispatchMultipleQueriesWithVariables.snap
index 101e2a23d84..c3a918ad743 100644
--- a/src/Stitching/Stitching.Tests/Client/__snapshots__/RemoteQueryClientTests.DispatchMultipleQueriesWithVariables.snap
+++ b/src/Stitching/Stitching.Tests/Client/__snapshots__/RemoteQueryClientTests.DispatchMultipleQueriesWithVariables.snap
@@ -189,7 +189,7 @@
},
"QueryName": null,
"QueryHash": null,
- "OperationName": null,
+ "OperationName": "exec_batch",
"VariableValues": {
"__0__a": "foo"
},
diff --git a/src/Stitching/Stitching.Tests/Delegation/ArgumentScopedVariableResolverTests.cs b/src/Stitching/Stitching.Tests/Delegation/ArgumentScopedVariableResolverTests.cs
index 03745d454bd..c852631cad2 100644
--- a/src/Stitching/Stitching.Tests/Delegation/ArgumentScopedVariableResolverTests.cs
+++ b/src/Stitching/Stitching.Tests/Delegation/ArgumentScopedVariableResolverTests.cs
@@ -1,5 +1,4 @@
using System;
-using ChilliCream.Testing;
using HotChocolate.Execution;
using HotChocolate.Language;
using HotChocolate.Resolvers;
@@ -24,10 +23,9 @@ public void CreateVariableValue()
});
var context = new Mock(MockBehavior.Strict);
- context.SetupGet(t => t.Field).Returns(
- schema.GetType("Query").Fields["foo"]);
- context.Setup(t => t.Argument