Code Monkey home page Code Monkey logo

farazmoallemi / elucid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oslabs-beta/elucid

0.0 0.0 0.0 25.1 MB

Elucid is an open-source error handling library for Javascript implementations of GraphQL providing developers with a lightweight solution to reduce ambiguity in GraphQL responses and HTTP headers. Use Elucid for better error-handling, testing, and debugging experiences.

Home Page: https://elucid.dev

License: ISC License

JavaScript 100.00%

elucid's Introduction

License: MIT AppVeyor AppVeyor contributions welcome

Elucid

Elucid: Added Insight for GraphQL.

Accelerated by OS Labs and developed by Khayal Alasgarov, Vivian Wu, Spencer Szu, and Giovanni Iacobucci.

Features

  • Extensible error detection and messaging for common graphQL issues deriving from server problems and bad queries.

Installation

Elucid can be installed an an npm package:

  • Download Elucid from npm in your terminal with npm i elucid.js

Installing and connecting with Express:

In its current form, Elucid extends express-graphql's server middleware, so you'll need your GraphQL HTTP server setup running Express (or a similar web framework that supports connect styled middleware, such as Connect or Restify) as a prerequisite. Please see the express-graphql documentation for more information on how to use the express-graphql route handler.

Usage notes

  • Currently, Elucid adds additional insight and status code manipulation for queries, but not mutations.

Getting started with Elucid

Here's an example of a typical server.js setup running Elucid:

const express = require('express');
const path = require('path');
const schema = require('./schema/schema');
const resolvers = require('./schema/resolvers');
const elucid = require('elucid.js');

const PORT = 3000;

const app = express();

app.use(express.json());

// Handle requests to GraphQL endpoint
app.use('/graphql', elucid({
  schema,
  resolvers,
  graphiql: true,
  pretty: true,
}));
  • Notice that after installation of its npm package, the Elucid function must be imported into your server file as a required module, 'elucid.js'.
  • Then, the elucid function is passed into the Express 'use' method as its second argument.
  • This is very similar to how express-graphql's 'graphqlHTTP' middleware function is used. In fact, the configuration object that elucid() takes as an argument passes its values through to an invocation of graphqlHTTP. That includes the keys 'schema' and 'resolvers' (note that these evaluate to your imported GraphQL schema and resolver files), as well as the config booleans 'graphiql' and 'pretty'.
  • At runtime, elucid() will kick off a sequence of events under the hood. GraphqlHTTP will process the request. If it doesn't catch an error on its own, Elucid's functionality will kick in to do its additional post-processing, which may include modifying the default response status code and returning a more detailed, useful context message in the 'elucid' property of the response object's 'extensions' property.

Contribute to Elucid

Interested in making a contribution to Elucid? Click for our open-source contribution guidelines.

Happy bug hunting/data fetching! Team Elucid

elucid's People

Contributors

alasgaroff avatar garyiacobucci avatar szuay avatar vw-in-github avatar

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.