Code Monkey home page Code Monkey logo

linql's Introduction

LinQL

LINQ-like access to GraphQL endpoints in .Net

Nuget

NuGet Badge

Supported Operations

  • Queries
  • Mutations
  • Input Types
  • Arguments
  • Interfaces/Unions
  • Auto-generating types via introspection
  • Subscriptions
  • Custom Scalars

Coming soon

  • Strawberry Shake support

Getting Started using GraphQL.Client

  1. Install the Nuget package
dotnet add package LinQL
dotnet add package LinQL.GraphQL.Client
  1. Reference a .graphql SDL in your csproj
<ItemGroup>
    <AdditionalFiles Include="StarWars.graphql" LinQLClientNamespace="StarWars.Types" />
</ItemGroup>
  1. 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());
  1. 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);
}

Getting Started using StrawberryShake

Coming soon...

What can I do with it?

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

Troubleshooting

There are a couple gotchas with the source generator that can be solved using the guides here

linql's People

Contributors

dibble-james avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ultimgos

linql's Issues

Custom Scalars

Mark a class as a custom scalar
Register a custom json serialiser

Add XML Docs

Also look into how to enforce it on public members via editorconfig

Generate records or classes

The source generator should switch on a build prop (LinQLTypesAs="[Class|Record]โ€œ) and auto generate classes or records accordingly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.