Apollo GraphQL Utility Library (Abandoned)

raw JSON →
0.9.7 verified Sun Apr 19 auth: no javascript abandoned

The `apollo-graphql` package, last updated as version 0.9.7 around 2019, served as an internal utility library within the Apollo Server monorepo (primarily during the Apollo Server v2 era). It provided foundational GraphQL-related utilities for schema manipulation, such as adding resolvers, merging schemas, concatenating type definitions, and printing schemas with directives. This package is now considered abandoned, with no further updates planned, and its functionalities have been either integrated directly into newer versions of `@apollo/server` or are handled by more modern, actively maintained libraries like `@graphql-tools/schema` or `@apollo/server` itself. Developers are strongly advised not to use `apollo-graphql` for new projects due to its age, lack of updates, potential security vulnerabilities, and incompatibility with modern `graphql` and Node.js environments.

error TypeError: (0 , apollo_graphql_1.addResolversToSchema) is not a function
cause Attempting to import `apollo-graphql` using ESM `import` syntax in an environment that doesn't correctly transpile legacy CommonJS modules, or when the `addResolversToSchema` function is not correctly resolved.
fix
Change your import statement to use CommonJS require(): const { addResolversToSchema } = require('apollo-graphql');.
error Cannot find module 'apollo-graphql'
cause The package `apollo-graphql` is not installed, or your module resolver (e.g., Webpack, Node.js) cannot locate it. This often happens if the package name is misspelled, or if it's not present in `node_modules`.
fix
Ensure the package is installed: npm install apollo-graphql or yarn add apollo-graphql. Also, verify that your project's module resolution paths are correctly configured.
error npm WARN apollo-graphql@0.9.7 requires a peer of graphql@^14.2.1 || ^15.0.0 but none is installed.
cause You have a version of `graphql` installed that is outside the range specified by `apollo-graphql`'s peer dependencies, or `graphql` is not installed at all.
fix
Install a compatible version of graphql, for example: npm install graphql@^15.0.0. However, the primary recommendation is to remove apollo-graphql entirely due to its abandonment.
breaking This package is explicitly abandoned and has not received updates since approximately 2019. It is not compatible with modern Node.js versions (e.g., Node.js 14+ ESM), current `graphql` library versions (v16+), or the latest `@apollo/server` releases.
fix Do not use this package. Migrate to `@apollo/server`, `@apollo/client`, or `@graphql-tools/schema` for equivalent functionalities.
gotcha The package primarily targets CommonJS environments. Attempting to use `import` statements directly will likely result in module resolution errors or runtime failures unless a robust transpilation pipeline (e.g., Babel, Webpack) is specifically configured for such legacy modules.
fix Ensure you are using `require()` for all imports from `apollo-graphql` in your JavaScript files. For TypeScript, ensure your `tsconfig.json`'s `module` option is set to `CommonJS` or that your bundler handles legacy CJS modules correctly.
breaking Security vulnerabilities are highly probable due to the package's age and lack of maintenance. Any reported CVEs or discovered weaknesses will not be patched, posing significant risks to applications that still depend on it.
fix Remove this package from your dependencies and replace its functionality with modern, actively maintained libraries from the Apollo ecosystem or `graphql-tools`.
gotcha The peer dependency on `graphql` specifies versions `^14.2.1 || ^15.0.0`. Installing this package with `graphql` v16 or higher will trigger peer dependency warnings and likely lead to runtime errors due to API changes in the `graphql` library itself.
fix If absolutely forced to use this package (not recommended), pin your `graphql` dependency to a compatible version (e.g., `^15.0.0`). The ultimate fix is to migrate away from `apollo-graphql`.
npm install apollo-graphql
yarn add apollo-graphql
pnpm add apollo-graphql

Illustrates the historical usage of `addResolversToSchema` from `apollo-graphql` within a CommonJS environment, emphasizing its abandonment and suggesting modern alternatives.

const { gql } = require('apollo-server-express');
const { addResolversToSchema } = require('apollo-graphql');
const { makeExecutableSchema } = require('@graphql-tools/schema');

// This example is for illustrative purposes only, showing historical usage.
// It is not recommended for current development.

const typeDefs = gql`
  type Query {
    hello: String
    greet(name: String!): String
  }
`;

const resolvers = {
  Query: {
    hello: () => 'Hello, world!',
    greet: (parent, { name }) => `Greetings, ${name}!`, 
  },
};

// Create a basic executable schema (using modern @graphql-tools for simplicity here)
let schema = makeExecutableSchema({ typeDefs });

// Historically, apollo-graphql's addResolversToSchema would be used.
// Note: This function might not be directly compatible with modern `graphql-tools` Schema types.
// For a truly historical setup, one would need older `graphql` and `graphql-tools` versions.
try {
  schema = addResolversToSchema(schema, resolvers);
  console.log('Schema with resolvers added (historical emulation):');
  // In a real scenario, you'd then pass this schema to Apollo Server v2
  // For demonstration, we'll just log a success message.
  console.log('Schema successfully augmented using addResolversToSchema.');
  console.log(require('graphql').printSchema(schema));
} catch (e) {
  console.error('Error attempting to use addResolversToSchema. This package is old and likely incompatible:', e.message);
}

// For current projects, use `@apollo/server` or `@graphql-tools/schema` directly.