Git Product home page Git Product logo

graphql_client's Introduction

graphql_client Build Status

UPDATE:

I am not actively working on the project at the moment. I would be more than happy to receive contributions and/or grant release permission to someone else. I like the dart ecosystem and I'd love to see a mature GraphQL library for it. I unfortunately don't have enough time to work on the project at the moment โ˜น๏ธ.

GraphQL Client written in Dart ๐ŸŽฏ.

Packages

This repository is the home of a set of packages for graphql_client:

The GraphQL client library.

A generator that transforms GQL query into the graphql_client.dsl.

graphql_client's People

Contributors

ekilmer avatar hourliert avatar sethladd 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  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_client's Issues

Remove mirrors usage

I'm more than willing to submit a PR for this, and to help with the development of this package.
I've written a GraphQL parser and GraphQL type implementation package for Dart, and am trying to get some server-side and cross-platform implementations going:

So I anticipate myself using the client a lot.

That being said, dart:mirrors can potentially cause a code size bloat via dart2js, and is entirely unsupported by Flutter. A potential solution might be some sort of code generation?

when value of resolved filed is List type, error throwed

when value of resolved field is List type, met error:

E/flutter (28080): type 'List<dynamic>' is not a subtype of type 'Map<dynamic, dynamic>'
E/flutter (28080): #0      GQLClient._resolve (package:graphql_client/src/client.dart:168:31)
E/flutter (28080): #1      GQLClient._resolveFields (package:graphql_client/src/client.dart:122:9)
E/flutter (28080): #2      GQLClient._resolveQuery (package:graphql_client/src/client.dart:115:5)
E/flutter (28080): #3      GQLClient.execute (package:graphql_client/src/client.dart:70:7)
...

my GraphQL query is:

query ActivitiesQuery {
   activities {
      id
   }
 }

and the http response body is:

{
  "data": {
    "activities": [
      {
        "id": "cjjb31t5rdjp701200999b2r1"
      }
    ]
  }
}

I noticed there is the ScalarCollection abstract class(mixin) and maybe it was designed for GraphQL pagination purpose.

Am I missing something how to handle value of List type field that is not follow GraphQL pagination format ? thx a lot.

Error when trying your sample BioQuery...

I am new to Dart... any hints on why? thx. Billy.

On this line: The IDE gives me a warning of Invalid Override.
OperationType get type => OperationType.query;

At runtime:
malformed type: line 93 pos 3: cannot resolve class 'OperationType' from 'ViewerBioQuery' OperationType get type => OperationType.query; ^

Support for none http clients

GraphQL doesn't have to be served over http. In Apollo, they have abstracted the network client away, while providing a default implementation. This is great for things like testing, support for subscriptions over websockets, or any other customization the user wants to make without having to support it in this library.

I would like this abstraction so that I could build a graphql server in dart to act as a proxy to the real graphql server. I would store all mutations while off network and handle them in dart, then next time the network is back online, I would send all of them to the real server.

I don't think this library should be responsible for this kind of functionality, so I think the network abstraction would be the best option.

Support string queries

Hey! Thanks for creating that lib. I'm going to look into at once I'm more familiar with the basics of dart again. It's been a long time...

I want to learn about your approach to create the queries like this:
https://github.com/hourliert/graphql_client/blob/716ddcae1b33a7400c99dd89fc96a0a6b0a948a6/example/graphql_client_example.dart#L27-L39

IMO it's way better to use simple string queries, run them and after getting the response marshall them into the objects you'd like to work with.
What makes this so much better to work with, is the fact that you can actually write the queries in GraphiQL and just copy & paste them over into your code. This is just not possible with the current approach and thus probably error prone.

Cheers ๐Ÿป

Test Issue

This issue will be used to test mutations.

GQLError shouldn't require 'locations'

I'm currently trying to run a mutation, which doesn't return locations, if there was an error.
Unfortunately, it seems like locations is required in case there was an error.

NoSuchMethodError: The method 'map' was called on null.
Receiver: null
Tried calling: map(Closure: (dynamic) => Location)
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
#1      new GQLError.fromJSON (package:graphql_client/src/exceptions.dart:39:33)
#2      new GQLException.<anonymous closure> (package:graphql_client/src/exceptions.dart:61:44)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
#4      ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
#5      new List.from (dart:core/runtime/libarray_patch.dart:51:29)
#6      new GQLException (package:graphql_client/src/exceptions.dart:61:7)
#7      GQLClient._parseResponse (package:graphql_client/src/client.dart:109:17)
#8      GQLClient.execute (package:graphql_client/src/client.dart:65:20)

Query:

mutation($username: String!, $password: String!) {
  createToken (username: $username, password: $password) { 
  	token
  }
}

Response:

{
  "data": {
    "createToken": null
  },
  "errors": [
    {
      "message": "Username and password required.",
      "path": [
        "createToken"
      ]
    }
  ]
}

Successfull request work as expected.
I've tried to modify exceptions.dart, but without luck. (Just started with Dart a few days ago.)

Using for calls between flutter and a flutter plugin

Could you make an example where you don't use an endpoint url ?

The reason is because I have to write plugins in golang and wrap in Java and swift. Graphql is a really nice way to avoid having to write a ton of java and swift code on a large API.
So from flutter I just call a single method and it passes through to the golang layer which then sees the query and does it's thing and returns the graphql response
It's not the fastest but it's convenient.
It's also kind of nice because I can use the same technique for making server caller from flutter also, which is when of course I do need an endpoint

Inside the plugin I use golang which has pretty good graphql support including resolvers.

If you want more info just ask.
If your super busy just say and I can try to do it myself and publish and example.

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.