Last active
August 26, 2021 10:21
-
-
Save benmccallum/9238cbadc558af9cc4491238f5104a41 to your computer and use it in GitHub Desktop.
Verify your GraphQL schema changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc.Testing; | |
using Snapshooter.Json; | |
using Xunit; | |
namespace MyCompany.MyService | |
{ | |
public class GraphQLSchemaTests | |
: IClassFixture<WebApplicationFactory<Startup>> | |
{ | |
private readonly WebApplicationFactory<Startup> _factory; | |
public GraphQLSchemaTests(WebApplicationFactory<Startup> factory) => _factory = factory; | |
[Fact] | |
public async Task Is_Approved_GraphQL_Schema() | |
{ | |
// Arrange | |
var client = _factory.CreateClient(); | |
// Act | |
var response = await client.GetAsync("/graphql?SDL"); // formerly /graphql/schema on v10 | |
// Assert | |
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | |
var schema = await response.Content.ReadAsStringAsync(); | |
Snapshot.Match(schema); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment