-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from byme8/feature/allow-wrappers
Feature/allow wrappers
- Loading branch information
Showing
43 changed files
with
504 additions
and
233 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
30 changes: 30 additions & 0 deletions
30
src/TestApp/ZeroQL.TestApp/Services/GraphQLClientMethodWrapper.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,30 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZeroQL.TestApp.Services; | ||
|
||
public class GraphQLClientMethodWrapper | ||
{ | ||
public static async Task<T?> MakeQuery<T, TQuery, TMutation>( | ||
GraphQLClient<TQuery, TMutation> client, | ||
[GraphQLLambda]Func<TQuery, T> query, | ||
[CallerArgumentExpression(nameof(query))] string queryKey = "") | ||
where T : class | ||
{ | ||
var result = await client.Query(query, queryKey: queryKey); | ||
|
||
if (result.Errors != null) | ||
{ | ||
Console.WriteLine("Errors:"); | ||
foreach (var error in result.Errors) | ||
{ | ||
Console.WriteLine(error.Message); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
return result.Data; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/TestApp/ZeroQL.TestApp/Services/GraphQLClientWrapper.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,28 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
using GraphQL.TestServer; | ||
|
||
namespace ZeroQL.TestApp.Services; | ||
|
||
public class GraphQLClientWrapper | ||
{ | ||
private readonly TestServerClient client; | ||
|
||
public GraphQLClientWrapper(TestServerClient client) | ||
{ | ||
this.client = client; | ||
} | ||
|
||
public async Task<TResult> QueryAsync<TResult>( | ||
[GraphQLLambda] | ||
Func<Query, TResult> query, | ||
[CallerArgumentExpression(nameof(query))] | ||
string queryKey = "") | ||
where TResult : class | ||
{ | ||
var result = await client.Query(query, queryKey: queryKey); | ||
|
||
return result.Data!; | ||
} | ||
} |
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
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
Oops, something went wrong.