-
Notifications
You must be signed in to change notification settings - Fork 1
Home
dibble-james edited this page Mar 14, 2023
·
7 revisions
- Queries
- Mutations
- Input Types
- Arguments
- Interfaces/Unions
- Auto-generating types via introspection
- Subscriptions
- Custom Scalars
- Strawberry Shake support
- Install the Nuget package
dotnet add package LinQL
dotnet add package LinQL.GraphQL.Client
- Reference a
.graphql
SDL in your csproj
<ItemGroup>
<AdditionalFiles Include="StarWars.graphql" LinQLClientNamespace="StarWars.Types" />
</ItemGroup>
- Create a client:
using StarWars.Types;
var client = new GraphQLHttpClient(
"https://swapi-graphql.netlify.app/.netlify/functions/index",
new SystemTextJsonSerializer(new JsonSerializerOptions().WithKnownInterfaces()))
.WithLinQL(new LinQLOptions().WithKnownScalars());
- Write queries!
using GraphQL.Client.Abstractions;
using StarWars.Types; // As defined by LinQLClientNamespace
public class StarWarsClient
{
private readonly IGraphQLClient graph;
public StarWarsClient(IGraphQLClient graph) => this.graph = graph;
public async Task<Film> GetFilmById(string id, CancellationToken cancellationToken)
=> await this.graph.SendAsync((Root x) => x.GetFilm(id), cancellationToken);
}
Coming soon...
A range of expressions can be converted as demonstrated by the TranslationProviderTests
.
If you come accross something that doesn't work, please raise an issue or a pull request with a supporting test.
For more help check out the docs
There are a couple gotchas with the source generator that can be solved using the guides here