GithubHelp home page GithubHelp logo

graphql-net-client's Introduction

graphql-net-client

Very simple GraphQL client for .NET/C#. Requires JSON.NET!

Typed result

class GqlObj
{
    public string name { get; set; }
    public string id { get; set; }
}

var client = new GraphQLClient("https://mygraphql.endpoint");
var query = @"
    query($id: String) { 
        someObject(id: $id) {
            id
            name
        }
    }
";
var obj = client.Query(query, new { id = "123" }).Get<GqlObj>("someObject");
if (obj != null)
{
    Console.WriteLine(obj.name);
}
else
{
    Console.WriteLine("Null :(");
}

Dynamic result

var client = new GraphQLClient("https://mygraphql.endpoint");
var query = @"
    query($id: String) { 
        someObject(id: $id) {
            id
            name
        }
    }
";
var obj = client.Query(query, new { id = "123" }).Get("someObject");
if (obj != null)
{
    Console.WriteLine((string)obj.name);
}
else
{
    Console.WriteLine("Null :(");
}

graphql-net-client's People

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  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  avatar  avatar  avatar  avatar

graphql-net-client's Issues

GraphQL client update for new .net framework

Hello!

I found your GraphQL client while looking in the internet. Wanted to use it. But looks like you haven't updated in a while and wondering and it will be very helpful if you could update to make it work for latest .netframework .

While I was trying, getting these errors - request does not have content length and response.GetResponseStream are not available. So I went and changed it to make it work by calling Task factory read and write like -
using (var dataStream = await Task.Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, null))
{
dataStream.Write(byteArray, 0, byteArray.Length);
}

but now getting errors in dynamic as I converted the method to be async. Getting this error in a class where I use these methods.
Task does not contain the method Get that accepts first argument of Task.

Could you please help me resolve this issue. Thank you and appreciate your help.

I am attaching two files that are applicable:

screen shot 2018-01-06 at 11 40 03 am
GraphQL.txt

Nivi

Code Generation not generating C# code for GraphQL interfaces

I'm trying to use ZeroQL to generate a C# client for a graphql schema that implements interfaces for some types and the interfaces are being ignored during the code generation.
For instance, the graphql snippet below does not generates any code.

interface Client { addresses: [ClientAddress!]! alternateId: String availableCommunicationParticipants: [CommunicationParticipant!]! availableCommunicationTemplates: [CommunicationTemplate!]! bankAccounts: [BankAccount!]! "Provides blacklist information related to this entity." blacklisting: BlacklistingContext! claims(filters: ClaimListFiltersInput order: ClaimOrderInput = { by: CREATED, direction: DESCENDING, then: null } pagination: OptionalPaginationInput): ClaimList! communications(filters: CommunicationListFiltersInput order: CommunicationOrderInput = { by: CREATE_DATE, direction: DESCENDING, then: null } pagination: OptionalPaginationInput): CommunicationList! contactDetails: [ContactDetail!]! countryOfOrigin: Country customFields: CustomFieldContext! externalId: String id: Int! invoiceBatches: [ClaimPurchaseInvoiceBatch!]! isActive: Boolean! isPinned: Boolean! isVip: Boolean! language: Culture membershipNumber: String name: String! organisation: Organisation! policies(pagination: OptionalPaginationInput): PolicyList! purchaseInvoicesAndGuarantees(filters: ClaimPurchaseInvoiceOrPaymentGuaranteeListFiltersInput order: ClaimPurchaseInvoiceOrPaymentGuaranteeOrderInput = { by: CREATE_DATE, direction: DESCENDING, then: null } pagination: OptionalPaginationInput): ClaimPurchaseInvoiceOrPaymentGuaranteeList! tasks(filters: TaskListFiltersInput order: TaskOrderInput = { by: COMPLETED, direction: null, then: { by: DATE, direction: null, then: null } } pagination: OptionalPaginationInput): TaskList! uid: UUID! }

Variables don't substitute

The examples show using $variables but I don't see anything in the class that does the token substitutes.

    private class GraphQLQuery
    {
        // public string OperationName { get; set; }
        public string query { get; set; }
        public object variables { get; set; }
    }

Support Authorization Tokens

I don't see anything in these classes to support API authorization. I can submit a pull request to support bearer token auth if you will accept it.

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.