Apollo GraphQL Utility Library (Abandoned)

0.9.7 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

view raw JSON →