Code Monkey home page Code Monkey logo

Comments (4)

HofmannZ avatar HofmannZ commented on May 18, 2024 8

Hi @sjmcdowall,

We are aware there is still a lack of documentation for this project. We're planning on creating some static docs.

Until then here are some pointers:

Updating http options though the context

You can update the http options (like headers) by passing them to context in the query. That would look something like this:

Query(
  options: QueryOptions(
    document: queries.readRepositories,
    pollInterval: 4,
    context: <String, dynamic>{
      'headers': <String, String>{
        'Authorization': 'Bearer <YOUR_PERSONAL_ACCESS_TOKEN>',
      },
    },
  ),
  builder: (QueryResult result) {
    ...
  },
);

Calling the client from outside a Flutter context

Although not (yet) documented, you can call the the client directly. The client exposes two methods: GraphQLClient.query and GraphQLClient.mutate. They both resolve a single query according to the options specified and return a Future which resolves with the resulting data or throws an error.

HttpLink link = HttpLink(
  uri: 'https://api.github.com/graphql',
  headers: <String, String>{
    'Authorization': 'Bearer <YOUR_PERSONAL_ACCESS_TOKEN>',
  },
);

GraphQLClient client = GraphQLClient(
  cache: InMemoryCache(),
  link: link,
);

Future<QueryResult> queryResult = client.query(
  QueryOptions(
    document: queries.readRepositories,
  ),
);

Hope that helps! ✌🏻

from graphql-flutter.

Moanrisy avatar Moanrisy commented on May 18, 2024 1

why this is not on documented yet?

from graphql-flutter.

sjmcdowall avatar sjmcdowall commented on May 18, 2024

That is perfect and awesome doc! Can't wait to give it a whirl later today!!

from graphql-flutter.

sjmcdowall avatar sjmcdowall commented on May 18, 2024

from graphql-flutter.

Related Issues (20)

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.