-
-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Playground Options Path Logic (#984)
- Loading branch information
1 parent
3e742a7
commit 1820eba
Showing
79 changed files
with
2,419 additions
and
207 deletions.
There are no files selected for viewing
This file contains 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
15 changes: 15 additions & 0 deletions
15
src/Core/Types.Filters.Tests/__snapshots__/StringFilterInputTypeTests.Ignore_Field_2.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
foo: String | ||
} | ||
|
||
input FooFilter { | ||
AND: [FooFilter!] | ||
OR: [FooFilter!] | ||
} | ||
|
||
"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." | ||
scalar String |
15 changes: 15 additions & 0 deletions
15
...ore/Types.Filters.Tests/__snapshots__/StringFilterInputTypeTests.Ignore_Field_Fields.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
foo: String | ||
} | ||
|
||
input FooFilter { | ||
AND: [FooFilter!] | ||
OR: [FooFilter!] | ||
} | ||
|
||
"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." | ||
scalar String |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
193 changes: 193 additions & 0 deletions
193
src/Server/AspNetClassic.Tests/GraphiQL/GraphiQLMiddlewareTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Snapshooter.Xunit; | ||
using Xunit; | ||
using HotChocolate.AspNetClassic.GraphiQL; | ||
using Microsoft.Owin.Testing; | ||
using Microsoft.Owin; | ||
|
||
namespace HotChocolate.AspNetClassic | ||
{ | ||
public class GraphiQLMiddlewareTests | ||
: ServerTestBase | ||
{ | ||
public GraphiQLMiddlewareTests(TestServerFactory serverFactory) | ||
: base(serverFactory) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task Default_Values() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task Disable_Subscriptions() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.EnableSubscription = false; | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.Path = new PathString("/foo"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/foo/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetPath_Then_SetQueryPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.Path = new PathString("/foo"); | ||
options.QueryPath = new PathString("/bar"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/foo/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetQueryPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.QueryPath = new PathString("/foo"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/foo/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetQueryPath_Then_SetPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.QueryPath = new PathString("/foo"); | ||
options.Path = new PathString("/bar"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/bar/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetQueryPath_Then_SetSubscriptionPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.QueryPath = new PathString("/foo"); | ||
options.SubscriptionPath = new PathString("/bar"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/foo/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetSubscriptionPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.SubscriptionPath = new PathString("/foo"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public async Task SetSubscriptionPath_Then_SetQueryPath() | ||
{ | ||
// arrange | ||
var options = new GraphiQLOptions(); | ||
options.SubscriptionPath = new PathString("/foo"); | ||
options.QueryPath = new PathString("/bar"); | ||
|
||
TestServer server = CreateServer(options); | ||
string settingsUri = "/bar/graphiql/settings.js"; | ||
|
||
// act | ||
string settings_js = await GetSettingsAsync(server, settingsUri); | ||
|
||
// act | ||
settings_js.MatchSnapshot(); | ||
} | ||
|
||
private TestServer CreateServer(GraphiQLOptions options) | ||
{ | ||
return ServerFactory.Create( | ||
services => services.AddStarWars(), | ||
(app, sp) => app.UseGraphQL(sp).UseGraphiQL(options)); | ||
} | ||
|
||
private async Task<string> GetSettingsAsync( | ||
TestServer server, | ||
string path) | ||
{ | ||
HttpResponseMessage response = | ||
await server.HttpClient.GetAsync( | ||
TestServerExtensions.CreateUrl(path)); | ||
response.EnsureSuccessStatusCode(); | ||
return await response.Content.ReadAsStringAsync(); | ||
} | ||
} | ||
} |
Oops, something went wrong.