A lightweight client for creating and sending GraphQL requests over Fetch API

A lightweight client for creating and sending GraphQL requests over Fetch API

A lightweight client for creating and sending GraphQL requests over Fetch API (without Schema/GQL Types validation)

Deno Fetch GraphQL

A lightweight client for creating and sending GraphQL requests over Fetch API (without Schema/GQL Types validation)

Examples

import {
  GraphQLClient,
  GraphQLRequest,
  OperationType,
} from "https://deno.land/x/fetch-graphql";

interface HelloInputVars {
  myName: string;
}

const helloQuery = {
    operationType: OperationType.Query,
    name: "Hello",
    variableDefs: [
      {
        name: "myName",
        graphqlType: "string!",
      },
    ],
    field: {
      name: "hello",
      args: [
        {
          name: "from",
          fromVariable: "myName",
        }
      ],
      children: [
        "message",
        "andMyNameIs",
        {
          name: "yourInfo",
          children: [
            "ipAddress",
            "lastLoginAt",
          ]
        }
      ],
  }
};

const countUpMutation = {
  operationType: OperationType.Mutation,
  field: {
    name: "countUp",
    args: [
      {
        name: "increment",
        value: 10,
        valueType: "Int!",
      }
    ],
  }
};

const client = new GraphQLClient({ url: "http://myserver:8080/graphql" });
const gqlRequest = new GraphQLRequest<HelloInputVars>()
  .add(helloQuery)
  .add(countUpMutation)
  .withAuthToken("jwt01234abcd")
  .withVariables({
    myName: "Q",
  });

const gqlResponse = await client.send({
  operationType: OperationType.Query
});

interface HelloResult {
  message: string;
  andMyNameIs: string;
}

const errors = gqlResponse.getErrors();
errors.forEach(console.error);

const result = gqlResponse.getData<HelloResult>(helloQuery);
console.log(result);

Download Details:

Author: quaos

Source Code: https://github.com/quaos/deno-fetch-graphql

deno nodejs node javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings