Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-server-errors

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-server-errors

  • 2.4.1-alpha.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

What is apollo-server-errors?

The apollo-server-errors package provides a set of error types and utilities for handling errors in a GraphQL server, specifically tailored for use with Apollo Server. It allows developers to create more descriptive and standardized error responses in their GraphQL APIs.

What are apollo-server-errors's main functionalities?

ApolloError

ApolloError is the base error that all other error classes extend. It allows you to throw errors in your resolvers with a message, an error code, and additional properties.

const { ApolloError } = require('apollo-server-errors');
throw new ApolloError('Message', 'CODE', { additional: 'properties' });

UserInputError

UserInputError is used to indicate an error when invalid input is provided by the user. It extends ApolloError, adding more context to client-side form validation errors.

const { UserInputError } = require('apollo-server-errors');
throw new UserInputError('Form Arguments invalid', { invalidArgs: Object.keys(args) });

AuthenticationError

AuthenticationError is used to signal an authentication failure. It is useful for resolvers that require the user to be authenticated.

const { AuthenticationError } = require('apollo-server-errors');
throw new AuthenticationError('You must be logged in');

ForbiddenError

ForbiddenError is used to indicate that the user is authenticated but does not have permission to perform a requested action.

const { ForbiddenError } = require('apollo-server-errors');
throw new ForbiddenError('You are not authorized to do this action');

Other packages similar to apollo-server-errors

FAQs

Package last updated on 02 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc