Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
apollo-server-errors
Advanced tools
Package description
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.
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');
graphql-errors is a package that allows you to mask and format GraphQL errors. While it provides similar functionality in terms of error handling, apollo-server-errors is more tightly integrated with Apollo Server and offers a richer set of predefined error types.
graphql-yoga-errors offers utilities for error handling in GraphQL Yoga, a fully-featured GraphQL Server. It is similar to apollo-server-errors but is designed to work within the GraphQL Yoga ecosystem, providing a different set of integrations and defaults.
FAQs
Unknown package
The npm package apollo-server-errors receives a total of 1,325,317 weekly downloads. As such, apollo-server-errors popularity was classified as popular.
We found that apollo-server-errors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.