Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] File System persisted queries #858

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a5ae8d3
Started a persisted queries project
willwolfram18 Jun 20, 2019
3b8fd94
Created read and write interfaces
willwolfram18 Jun 20, 2019
09743a7
Created a QueryNotFound exception
willwolfram18 Jun 20, 2019
87b6215
Simple WIP for file system storage
willwolfram18 Jun 20, 2019
00b0cdd
Minor text changes
willwolfram18 Jun 20, 2019
0ffbc86
Included query id on exception
willwolfram18 Jun 20, 2019
6ad92b4
Merge branch 'master' into feature/persisted-queries
michaelstaib Jun 21, 2019
dace36a
Merge branch 'master' into feature/persisted-queries
michaelstaib Jun 21, 2019
908087a
Merge branch 'master' into feature/persisted-queries
michaelstaib Jun 25, 2019
7836c84
Started a persisted queries project
willwolfram18 Jun 20, 2019
9579f6d
Created read and write interfaces
willwolfram18 Jun 20, 2019
5a78e87
Created a QueryNotFound exception
willwolfram18 Jun 20, 2019
392b9f4
Simple WIP for file system storage
willwolfram18 Jun 20, 2019
fdf440b
Minor text changes
willwolfram18 Jun 20, 2019
683b50c
Included query id on exception
willwolfram18 Jun 20, 2019
da990a3
Merge branch 'feature/persisted-queries' of https://github.com/willwo…
willwolfram18 Jun 27, 2019
d6788db
Started a persisted queries project
willwolfram18 Jun 20, 2019
7c6202d
Created read and write interfaces
willwolfram18 Jun 20, 2019
0cca0df
Created a QueryNotFound exception
willwolfram18 Jun 20, 2019
e5cf98b
Simple WIP for file system storage
willwolfram18 Jun 20, 2019
7ff0be1
Minor text changes
willwolfram18 Jun 20, 2019
711896f
Included query id on exception
willwolfram18 Jun 20, 2019
399bd2c
Started a persisted queries project
willwolfram18 Jun 20, 2019
dbd0227
Created read and write interfaces
willwolfram18 Jun 20, 2019
5433b22
Created a QueryNotFound exception
willwolfram18 Jun 20, 2019
389f8a1
Merge branch 'feature/persisted-queries' of https://github.com/willwo…
willwolfram18 Jun 28, 2019
74cd598
Refactored method names
willwolfram18 Jun 28, 2019
286d371
Starting FileSystem unit tests
willwolfram18 Jun 28, 2019
8dd28d7
Some more tests
willwolfram18 Jun 28, 2019
3814016
Merge branch 'master' into feature/persisted-queries
michaelstaib Jul 1, 2019
f41bdc1
Working on integrating query parser
willwolfram18 Jul 2, 2019
88f2153
Merge branch 'master' into feature/persisted-queries
michaelstaib Jul 4, 2019
92b2db4
Merge branch 'master' into feature/persisted-queries
michaelstaib Jul 8, 2019
e5c42b3
Unit testing with query builder
willwolfram18 Jul 16, 2019
128286c
Started Azure and AWS projects
willwolfram18 Jul 16, 2019
9fac425
Basic AzureBlobStorage implementation
willwolfram18 Jul 16, 2019
d7ec10e
Simple error handling
willwolfram18 Jul 16, 2019
695d54c
Merge branch 'master' into feature/persisted-queries
willwolfram18 Jul 16, 2019
fe1b303
Merge branch 'master' into feature/persisted-queries
michaelstaib Jul 17, 2019
31d4f7f
Merge branch 'master' into feature/persisted-queries
michaelstaib Jul 18, 2019
84eba23
Exception for invalid Blob container name
willwolfram18 Jul 25, 2019
166aafc
Merged Changes
michaelstaib Jul 31, 2019
4f86712
Reworked interfaces and added more tooling
michaelstaib Jul 31, 2019
a5366e9
cleanup
michaelstaib Jul 31, 2019
3ff01b7
implemented file storage
michaelstaib Jul 31, 2019
bca7222
dependency injection helpers
michaelstaib Jul 31, 2019
7c5af79
moved interfaces to abstractions
michaelstaib Jul 31, 2019
272d1c6
added persisted query middleware
michaelstaib Jul 31, 2019
987cbf7
Cleaned up solutions
michaelstaib Aug 4, 2019
34706cf
Deleted current set of tests
michaelstaib Aug 4, 2019
1756b3e
Fixed test project file
michaelstaib Aug 4, 2019
391020e
Added middleware to handle persisted queries
michaelstaib Aug 4, 2019
cd92138
Merge branch 'master' into feature/persisted-queries
michaelstaib Aug 4, 2019
6e754d5
query builder optimization
michaelstaib Aug 5, 2019
8640cbf
Added query execution builder tests
michaelstaib Aug 5, 2019
fb7d9c2
Added persisted query flows
michaelstaib Aug 5, 2019
70f1994
Added redis support
michaelstaib Aug 5, 2019
6aa075e
Updated snapshots
michaelstaib Aug 5, 2019
0e5205b
Added new test projects
michaelstaib Aug 5, 2019
2c0c0be
fixed cache resolve in parser middleware
michaelstaib Aug 5, 2019
e9bdd7c
Added dependency injection tests for file system query storage
michaelstaib Aug 5, 2019
eb088df
Added write test
michaelstaib Aug 5, 2019
d101e56
Fixed culture for parser
michaelstaib Aug 5, 2019
45e0060
Added file system storage tests
michaelstaib Aug 5, 2019
985b295
updated snapshot
michaelstaib Aug 5, 2019
9d398c3
refactored pipeline config
michaelstaib Aug 5, 2019
8df7eff
Added redis query storage tests
michaelstaib Aug 5, 2019
5f64eba
fixed interface
michaelstaib Aug 5, 2019
e1d394f
cleanuo
michaelstaib Aug 5, 2019
9e1a3ac
fixed more sonar issues
michaelstaib Aug 5, 2019
f197d86
optimized write persisted query middleware
michaelstaib Aug 5, 2019
d83cf80
more optimizations
michaelstaib Aug 5, 2019
43038ca
optimized if
michaelstaib Aug 5, 2019
a15c36a
fixed more sonar issues
michaelstaib Aug 5, 2019
39bd707
fixed more sonar issues
michaelstaib Aug 5, 2019
1d8ec47
more sonar cleanups
michaelstaib Aug 5, 2019
0da813c
more sonar cleanups
michaelstaib Aug 5, 2019
b4d5e47
removed unused code
michaelstaib Aug 5, 2019
0afea28
added more tests
michaelstaib Aug 5, 2019
4e3f6cf
Updated changelog
michaelstaib Aug 5, 2019
38864ed
fixed cache issue
michaelstaib Aug 5, 2019
1b048e1
reformatted file
michaelstaib Aug 5, 2019
531f329
Fixed caching test
michaelstaib Aug 5, 2019
e0ad1b0
Added one more tweak
michaelstaib Aug 5, 2019
04a676c
Fixed service collection tests
michaelstaib Aug 5, 2019
3e03f61
reverted back to old cache implementation
michaelstaib Aug 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added new syntax visitor API.
- Added Redis subscription provider [#902](https://github.com/ChilliCream/hotchocolate/pull/902)
- Added support for batching over HTTP [#933](https://github.com/ChilliCream/hotchocolate/pull/933)
- Added support for persisted queries and added a middleware to enable the active persisted query flow. [#858](https://github.com/ChilliCream/hotchocolate/pull/858)

### Changed

Expand Down
46 changes: 45 additions & 1 deletion src/Core/Abstractions.Tests/Execution/QueryDocumentTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.IO;
using System;
using HotChocolate.Language;
using Snapshooter.Xunit;
using Xunit;
using System.Threading.Tasks;

namespace HotChocolate.Execution.Tests
{
Expand Down Expand Up @@ -55,7 +57,49 @@ public void QueryDocument_ToSource()

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(query.ToSource()))
Utf8GraphQLParser.Parse(query.ToSpan()))
.ToString().MatchSnapshot();
}

[Fact]
public async Task QueryDocument_WriteToAsync()
{
// arrange
DocumentNode document = Utf8GraphQLParser.Parse("{ a }");
var query = new QueryDocument(document);
byte[] buffer;

// act
using (var stream = new MemoryStream())
{
await query.WriteToAsync(stream);
buffer = stream.ToArray();
}

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(buffer))
.ToString().MatchSnapshot();
}

[Fact]
public void QueryDocument_WriteTo()
{
// arrange
DocumentNode document = Utf8GraphQLParser.Parse("{ a }");
var query = new QueryDocument(document);
byte[] buffer;

// act
using (var stream = new MemoryStream())
{
query.WriteTo(stream);
buffer = stream.ToArray();
}

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(buffer))
.ToString().MatchSnapshot();
}
}
Expand Down
183 changes: 183 additions & 0 deletions src/Core/Abstractions.Tests/Execution/QueryRequestBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,188 @@ public void BuildRequest_QueryAndTryAddVariable_VariableIsNotSet()
// assert
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndTryAddExtension_ExtensionIsSet()
{
// arrange
// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.TryAddExtension("one", "bar")
.Create();

// assert
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndTryAddExtension_ExtensionIsNotSet()
{
// arrange
// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.TryAddExtension("one", "bar")
.Create();

// assert
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndAddExtension_RequestIsCreated()
{
// arrange
// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.Create();

// assert
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_1()
{
// arrange
// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.SetExtensions(new Dictionary<string, object>
{
{ "three", "baz" }
})
.Create();

// assert
// only three should exist
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_2()
{
// arrange
IReadOnlyDictionary<string, object> ext =
new Dictionary<string, object>
{
{ "three", "baz" }
};

// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.SetExtensions(ext)
.Create();

// assert
// only three should exist
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_3()
{
// arrange
IReadOnlyDictionary<string, object> ext =
new Dictionary<string, object>
{
{ "three", "baz" }
};

// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.SetExtensions(ext)
.AddExtension("four", "bar")
.Create();

// assert
// only three should exist
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_4()
{
// arrange
IDictionary<string, object> ext =
new Dictionary<string, object>
{
{ "three", "baz" }
};

// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.SetExtensions(ext)
.Create();

// assert
// only three should exist
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtensions_RequestIsCreated_5()
{
// arrange
IDictionary<string, object> ext =
new Dictionary<string, object>
{
{ "three", "baz" }
};

// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.AddExtension("two", "bar")
.SetExtensions(ext)
.AddExtension("four", "bar")
.Create();

// assert
// only three should exist
request.MatchSnapshot();
}

[Fact]
public void BuildRequest_QueryAndSetExtension_RequestIsCreated()
{
// arrange
// act
IReadOnlyQueryRequest request =
QueryRequestBuilder.New()
.SetQuery("{ foo }")
.AddExtension("one", "foo")
.SetExtension("one", "bar")
.Create();

// assert
// one should be bar
request.MatchSnapshot();
}
}
}
46 changes: 45 additions & 1 deletion src/Core/Abstractions.Tests/Execution/QuerySourceTextTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Threading.Tasks;
using HotChocolate.Language;
using Snapshooter.Xunit;
using Xunit;
Expand Down Expand Up @@ -49,7 +51,49 @@ public void QueryDocument_ToSource()

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(query.ToSource()))
Utf8GraphQLParser.Parse(query.ToSpan()))
.ToString().MatchSnapshot();
}

[Fact]
public async Task QuerySourceText_WriteToAsync()
{
// arrange
DocumentNode document = Utf8GraphQLParser.Parse("{ a }");
var query = new QuerySourceText("{ a }");
byte[] buffer;

// act
using (var stream = new MemoryStream())
{
await query.WriteToAsync(stream);
buffer = stream.ToArray();
}

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(buffer))
.ToString().MatchSnapshot();
}

[Fact]
public void QuerySourceText_WriteTo()
{
// arrange
DocumentNode document = Utf8GraphQLParser.Parse("{ a }");
var query = new QuerySourceText("{ a }");
byte[] buffer;

// act
using (var stream = new MemoryStream())
{
query.WriteTo(stream);
buffer = stream.ToArray();
}

// assert
QuerySyntaxSerializer.Serialize(
Utf8GraphQLParser.Parse(buffer))
.ToString().MatchSnapshot();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
a
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
"QueryName": null,
"QueryHash": null,
"OperationName": null,
"VariableValues": null,
"VariableValues": {},
"InitialValue": null,
"Properties": null,
"Services": null
"Properties": {},
"Services": null,
"Extensions": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"QueryName": null,
"QueryHash": null,
"OperationName": null,
"VariableValues": null,
"VariableValues": {},
"InitialValue": null,
"Properties": null,
"Services": null
"Properties": {},
"Services": null,
"Extensions": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Query": {
"Text": "{ foo }"
},
"QueryName": null,
"QueryHash": null,
"OperationName": null,
"VariableValues": {},
"InitialValue": null,
"Properties": {},
"Services": null,
"Extensions": {
"one": "foo",
"two": "bar"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"QueryName": null,
"QueryHash": null,
"OperationName": null,
"VariableValues": null,
"VariableValues": {},
"InitialValue": null,
"Properties": {
"one": "foo",
"two": "bar"
},
"Services": null
"Services": null,
"Extensions": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"two": "bar"
},
"InitialValue": null,
"Properties": null,
"Services": null
"Properties": {},
"Services": null,
"Extensions": {}
}
Loading