GraphErr is an open-source error handling library for GraphQL implementations in Deno. It's a lightweight solution that provides developers with descriptive error messages, reducing ambiguity and improving debugging.

Overview

GraphErr

Descriptive GraphQL error handling for Deno/Oak servers.

Features

  • Provides additional context to GraphQL's native error messaging for faster debugging.
    • Classifies the error type and includes a link to the GraphQL spec for more information about the error.
  • Gives descriptive error messages to null responses, identifying the cause of the issue.
    • Traditionally, GraphQL null responses lack error messaging.
  • Enables quick development of GraphQL-equipped router.
  • Generates GraphQL Playground IDE, allowing developers to write and execute queries.

Getting Started with GraphErr

Below is an example of a basic server you can use to run GraphErr. This server will run on http://localhost:3000/graphql by default.

import { applyGraphQL } from "https://deno.land/x/grapherr/applyGQL.ts";
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
import { gql } from 'https://deno.land/x/graphql_tag/mod.ts';

const app = new Application();

// Define the GQL schema using GraphQL-tag (gql). More information on GraphQL-tag below in the README.
const typeDefs = gql`
  type Query {
    allUsers: [User!]!
  }
  type User {
    _id: ID!
    username: String!
    password: String!
  }
`;

// Define resolvers
const resolvers = {
  Query: {
    allUsers: () => {
      return [
      { _id: 1, username: 'JohnDoe', password: 'Password123!' }, 
      { _id: 2, username: 'JaneDoe', password: 'Password1234!!' }
      ]
    },
  },
};

const GraphQLService = await applyGraphQL<Router>({
  Router,
  typeDefs: typeDefs,
  resolvers: resolvers,
})

app.use(GraphQLService.routes(), GraphQLService.allowedMethods());

await app.listen({ port: 3000 });
  • Please import all necessary 3rd party modules (graphErr, oak, and gql).
    • Oak is a middleware framework for handling HTTP requests.
    • GraphQL-tag (gql) is a Javascript template literal tag that parses GraphQL query strings into the standard GraphQL AST.
  • Define typedefs (using GraphQL-tag) and resolvers and pass both into applyGraphQL as shown in the code above.
  • ApplyGQL accepts four arguments:
    • Router: oak Router module
    • path?: string
      • A target path that handles the GraphQL post request (*optional: default as /graphql)
    • typeDefs: any
      • generated type tags by the gql
    • resolvers: any
      • An object that handles the queries and mutations
  • ApplyGQL utilizes code from the Oak-GraphQL module. For additional information on ApplyGQL, please check out the OakGQL repository.

Making a Query

Here is an example query in the GraphQL playground:

query {
  allUsers {
    username
  }
}

The response would look like:

example query for getting all users with username

Functionality

Example #1 - Null response

Standard response:

Example query without graphErr response for non native GraphQL err

GraphErr response:

Example query with graphErr response for non native GraphQL err

Example #2 - Native GraphQL error

Standard response:

Example query without graphErr response for handling native GraphQL err

GraphErr response:

Example query with graphErr response for handling native GraphQL err

Suggestions

GraphErr is currently in beta. If you would like to contribute please contact the authors.

Notice any issues or bugs? Please open an issue. All feedback is greatly appreciated!

Authors

Thomas Seo

Maxwell Cook

Clay Sawyer

Loralyn Milcarek

Avi Kerson

Documentation

Website: graphErr.land

Medium: Introducing graphErr: solving GraphQL’s questionable query response quirks

You might also like...

Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord.

Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord.

Pagination Manager Pagination Manager is an useful framework for improving the use of object pagination in APIs like Discord. Lightweight module, ES6

Jul 26, 2022

A set of APIs for handling HTTP and HTTPS requests with Deno 🐿️ 🦕

oak commons A set of APIs that are common to HTTP/HTTPS servers. HTTP Methods (/method.ts) A set of APIs for dealing with HTTP methods. Content Negoti

May 23, 2022

Provides event handling and an HTMLElement mixin for Declarative Shadow DOM in Hotwire Turbo.

Turbo Shadow Provides event handling and an HTMLElement mixin for Declarative Shadow DOM support in Hotwire Turbo. Requires Turbo 7.2 or higher. Quick

Sep 28, 2022

It's a repository to studies. Its idea is to learn about Nx and its plugins.

It's a repository to studies. Its idea is to learn about Nx and its plugins.

StudyingNx This project was generated using Nx. 🔎 Smart, Fast and Extensible Build System Adding capabilities to your workspace Nx supports many plug

May 13, 2022

Can see everything, beware of its omniscience, kneel before its greatness.

Can see everything, beware of its omniscience, kneel before its greatness.

Can see everything, beware of its omniscience, kneel before its greatness. Summary Presentation Installation Removing Credits Presentation Main goal T

Sep 30, 2022

Theme Redone is a custom WordPress theme starter/framework with its own Gutenberg blocks solution and a CLI that speeds up the block creation process.

Theme Redone is a custom WordPress theme starter/framework with its own Gutenberg blocks solution and a CLI that speeds up the block creation process.

Theme Redone The Framework for Developing Custom WordPress Themes with its own Gutenberg Blocks creation solution. Theme Redone is a custom WordPress

Dec 30, 2022

A chat logs online saver for discord bots to save messages history & cleared messages online

A chat logs online saver for discord bots to save messages history & cleared messages online

Chat Logs NPM package that saves messages online to view it later Useful for bots where users can save messages history & cleared messages online Supp

Dec 28, 2022

Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding problems are pulled from LeetCode and Daily Coding Problem.

technical-interview-prep Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding

Aug 5, 2022
Comments
  • error you sample

    error you sample

    i have eror in deno 1.24 version sample code :

    import { applyGraphQL } from "https://deno.land/x/grapherr/applyGQL.ts";
    import { Application, Router } from "https://deno.land/x/oak/mod.ts";
    import { gql } from 'https://deno.land/x/graphql_tag/mod.ts';
    
    const app = new Application();
    
    // Define the GQL schema using GraphQL-tag (gql). More information on GraphQL-tag below in the README.
    const typeDefs = gql`
      type Query {
        allUsers: [User!]!
      }
      type User {
        _id: ID!
        username: String!
        password: String!
      }
    `;
    
    // Define resolvers
    const resolvers = {
      Query: {
        allUsers: () => {
          return [
          { _id: 1, username: 'JohnDoe', password: 'Password123!' }, 
          { _id: 2, username: 'JaneDoe', password: 'Password1234!!' }
          ]
        },
      },
    };
    
    const GraphQLService = await applyGraphQL<Router>({
      Router,
      typeDefs: typeDefs,
      resolvers: resolvers,
    })
    
    app.use(GraphQLService.routes(), GraphQLService.allowedMethods());
    
    await app.listen({ port: 3000 });
    console.log("jalan 3000")
    

    error message:

    Warning Implicitly using latest version (0.152.0) for https://deno.land/std/mime/multipart.ts
    Download https://deno.land/[email protected]/mime/multipart.ts
    error: Module not found "https://deno.land/std/mime/multipart.ts".
        at https://deno.land/x/[email protected]/deps.ts:144:33
    [E] [daem] app crashed - waiting for file changes before starting ...
    

    run : deno run -A server.ts

    opened by bobwatcherx 0
Releases(v1.0.3)
Owner
OSLabs Beta
OSLabs Beta
Colorconsole provides an interesting way to display colored info, success, warning and error messages on the developer console in your browser

ColorConsole NPM Package Colorconsole provides an interesting way to display colored info, success, warning and error messages on the developer consol

Hasin Hayder 17 Sep 19, 2022
1kb js library contains development debugging, error monitoring and reporting, user problem localization features

1kb js library contains development debugging, error monitoring and reporting, user problem localization features

腾讯 AlloyTeam 1.4k Dec 22, 2022
A JavaScript library improving inspection of objects

Pro Inspector A JavaScript utility improving inspection of objects on Node.js. Introduction Let's suppose that we have this declaration. class Person

Reiryoku Technologies 60 Dec 30, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An indexer that aggregates and normalizes NFT related data on the Tezos Blockchain and provides a GraphQL API for developers.

TezTok Token Indexer An indexer that aggregates and normalizes NFT related data on the Tezos Blockchain and provides a GraphQL API for developers. Not

null 29 Dec 23, 2022
GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schemas (Federation, Stitching)

GraphQL Hive GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schem

Kamil Kisiela 184 Dec 21, 2022
Superlight vanilla javascript plugin improving forms look and functionality

Superlight pure javascript form switch plugin by LCweb Give a modern look to your applications and take advantage of javascript events and public func

Luca 31 Mar 9, 2022