public GraphQLController( IDocumentExecuter executer, IDocumentWriter writer, StarWarsSchema schema) { _executer = executer; _writer = writer; _schema = schema; _namedQueries = new Dictionary<string, string> { ["a-query"] = @"query foo { hero { name } }" }; }
public async Task Synchronous_and_Async_Works_Same(IGraphQLTextSerializer serializer) { //ISSUE: manually created test instance with ServiceProvider var builder = new MicrosoftDI.GraphQLBuilder(new ServiceCollection(), b => new StarWarsTestBase().RegisterServices(b.Services)); var schema = new GraphQL.StarWars.StarWarsSchema(builder.ServiceCollection.BuildServiceProvider()); var result = await new DocumentExecuter().ExecuteAsync(new ExecutionOptions { Schema = schema, Query = "IntrospectionQuery".ReadGraphQLRequest() }).ConfigureAwait(false); var syncResult = serializer.Serialize(result); var stream = new System.IO.MemoryStream(); await serializer.WriteAsync(stream, result).ConfigureAwait(false); var asyncResult = System.Text.Encoding.UTF8.GetString(stream.ToArray()); syncResult.ShouldBe(asyncResult); }