GithubHelp home page GithubHelp logo

pekkah / tanka-graphql Goto Github PK

View Code? Open in Web Editor NEW
60.0 4.0 4.0 9.44 MB

GraphQL server and execution libraries

Home Page: https://pekkah.github.io/tanka-graphql/

License: MIT License

C# 98.80% HTML 0.14% PowerShell 0.48% CSS 0.14% Handlebars 0.43%
dotnet graphql nuget

tanka-graphql's Introduction

Tanka GraphQL library

  • Execute queries, mutations and subscriptions
  • Validation
  • Source Generator based source code generation (Schema types from classes)
  • New and improved parser for executable and type system documents
  • Delegates as resolvers and subscriptions (also middleware)
  • New middleware based execution pipelines (since v3)
  • New server and executor implementations (since v3)
  • Apollo Federation subgraph support (since v3)
  • graphql-ws compatible web socket server (compatible with latest Apollo Client) (since v3)

Documentation and packages

Both beta and release packages are available from NuGet and NPM

Nuget Nuget (with prereleases)

Samples

See Samples in the repository. See Tanka Chat for a more complete example.

Install

dotnet package add Tanka.GraphQL
dotnet package add Tanka.GraphQL.Server

Run benchmarks

src\GraphQL.benchmarks> dotnet run --configuration release --framework net8.0

tanka-graphql's People

Contributors

azure-pipelines[bot] avatar benmccallum avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar pekkah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tanka-graphql's Issues

Input for mutation type can only bind data in the last field

I'm not sure if it is a bug or not, but when I created the input type with multiple fields like

input CreateProductInput {
  name: String!
  price: Float!
  imageUrl: String
  desc: String
}

with mutation type

type Mutation {
  createProduct(message: CreateProductInput!): Product!
}
schema {
  query: Query
  mutation: Mutation
}

on the server side, I have created CoolStoreResolvers class

public class CoolStoreResolvers : ResolverMap
{
    public CoolStoreResolvers(ICoolStoreResolverService resolverService)
    {
        
        this["Mutation"] = new FieldResolverMap
        {
            {"createProduct",  resolverService.CreateProductAsync}
        };
    }
}

and CoolStoreResolverService as

public class CoolStoreResolverService : ICoolStoreResolverService
{
    public async Task<IResolveResult> CreateProductAsync(ResolverContext context)
    {
        var input = context.GetArgument<CreateProductRequest>("message");
		
		// do something		

        return await Task.FromResult(As(product));
    }
}

I tested with graphiql with the test data like

mutation createProduct($message: CreateProductInput!) {
  createProduct(message: $message) {
    name
	price
	desc
  }
}

Input variables as below

{
  "message": {
    "name": "product 1",
    "price": 100,
    "desc": "this is product 1"
  }
}

In the code above, I always got only desc field binding data with the string this is product 1, and the rest of fields such as name, price and imageUrl were null.

I have seen the samples folder from this project only have one field for input type as

input InputMessage {
    content: String!
}

Is it because this library could not bind multiple field data for input type?

I used

<PackageReference Include="tanka.graphql" Version="0.3.1" />
<PackageReference Include="tanka.graphql.server" Version="0.3.1" />

Support apollo link ws

For compatibility with existing GraphQL services this would be required to integrate with them

Review schema initialization

Currently initializing schema requires several async phases. This leads extra complications when used with IoC services which do not support async registrations.

Directives round 2

Should be only on these locations in type system:

 public static IEnumerable<DirectiveLocation> TypeSystemLocations = new[]
        {
            DirectiveLocation.SCHEMA,
            DirectiveLocation.SCALAR,
            DirectiveLocation.OBJECT,
            DirectiveLocation.FIELD_DEFINITION,
            DirectiveLocation.ARGUMENT_DEFINITION,
            DirectiveLocation.INTERFACE,
            DirectiveLocation.UNION,
            DirectiveLocation.ENUM,
            DirectiveLocation.ENUM_VALUE,
            DirectiveLocation.INPUT_OBJECT,
            DirectiveLocation.INPUT_FIELD_DEFINITION
        };

Review validation

  • It's slow. Based on benchmarks it takes most of the execution time with simple schema.

Create executable schema from model classes

public class SchemaRoot
{
    public Task<Query> GetQuery()...
}

public class Query 
{
    public Task<User> GetUser(int id)...
}

var schema = await SchemaGenerator.FromModelAsync(new SchemaRoot());

Optional List on input breaks instrospection in GraphQL client

In v0.10.0,

Currently, the schema below breaks introspection in GraphQL Clients
(Tested with GraphQL Playground, Altair GraphQL Client)

Example Schema

input InputItem {
  name: String
  foo: [String]
}

type Mutation {
  createItem(input: InputItem!): ID
}

This is due to defaultValue being assigned as System.Object[]

Question about using message broker

Hi @pekkah. I really appreciate this project because it helps me a lot for the idea to make GraphQL.NET works with SignalR. I'm refactoring to try this project, but could you please help to explain a bit about how it works if we use some of the message brokers out there such as RabbitMQ or Kafka? I think I will interfere with BroadcastBlock, right? And how it can subscribe after we publish an event from other publishers?

Path is calculated wrong

In the trace the path is wrong this would indicate that the path calculation is not working as it should

Authentication/authorization question

Hi @pekkah. How about authentication/authorization if we use this library. I have seen that we have X-Requested-With with the value authorization at

policy.WithHeaders("X-Requested-With", "authorization");
. Is it what we do with the key authentication from the client side. With GraphQL.NET, there is https://github.com/graphql-dotnet/authorization for doing authn/authz for the system. My question is how can we do it in this lib or is it planning to do in next phase?

Add Convenience Middleware for GraphiQL, Playground and Voyager

Similar to the graphql-dotnet/server offering

// use graphiQL middleware at default url /graphiql
app.UseGraphiQLServer(new GraphiQLOptions());

// use graphql-playground middleware at default url /ui/playground
app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
    
// use voyager middleware at default url /ui/voyager
app.UseGraphQLVoyager(new GraphQLVoyagerOptions());

If this is reasonable, I'd be willing to take a stab at making a PR for this.

Dependabot couldn't find a package.json for this project

Dependabot couldn't find a package.json for this project.

Dependabot requires a package.json to evaluate your project's current JavaScript dependencies. It had expected to find one at the path: /samples/graphql.samples.chat.ui/package.json.

If this isn't a JavaScript project, or if it is a library, you may wish to disable updates for it from within Dependabot.

You can mention @dependabot in the comments below to contact the Dependabot team.

Differences From graphql-dotnet/server

@pekkah Just saw your comment on graphql-dotnet/server#193. What are the main reasons for forking the code and starting again? I see the addition of Signal-R as being super valuable because it has a backplane already implemented, there is an open issue in graphql-dotnet/server to implement that. It also seems to be schema first which I think is the direction that people are going.

Also, what is the quality of this project, alpha, beta?

Bug with rule R5421RequiredArguments

System.InvalidCastException: Unable to cast object of type 'GraphQLParser.AST.GraphQLVariable' to type 'System.IConvertible'.
at System.Convert.ToInt64(Object value, IFormatProvider provider)
at tanka.graphql.type.converters.LongConverter.ParseValue(Object input) in D:\a\1\s\src\graphql\type\converters\LongConverter.cs:line 20
at tanka.graphql.validation.ExecutionRules.g__ValidateArguments|8_1(IEnumerable1 keyValuePairs, List1 graphQLArguments, IRuleVisitorContext ruleVisitorContext) in D:\a\1\s\src\graphql\validation\ExecutionRules.cs:line 347
at tanka.graphql.validation.RulesWalker.BeginVisitFieldSelection(GraphQLFieldSelection selection) in D:\a\1\s\src\graphql\validation\RulesWalker.cs:line 135

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.