Registry / devops / graphql-codegen-apollo-next-ssr

graphql-codegen-apollo-next-ssr

JSON →
library1.7.4jsnpmunverified

GraphQL Code Generator plugin for generating Apollo Client cache utilities and typed getServerSideProps in Next.js SSR. Current version 1.7.4, released 2022-05-12. Depends on graphql < 17.0.0. The plugin provides a typesafe getServerSideProps for each GraphQL query and a corresponding HOC to wrap the React component, avoiding multiple render passes required by getDataFromTree. The project is in maintenance mode and maintainer is needed; an alternative swr-gql solution is recommended. Key differentiator: it works with getServerSideProps (not getInitialProps) and generates cache read/write functions tailored for Apollo client integrations. Note: it uses the standard plugin configuration schema from graphql-codegen and outputs files with Apollo cache operations.

npm install graphql-codegen-apollo-next-ssr
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN-AP
G
graphql-codegen-apollo-next-ssr
devopsjavascriptv1.7.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

// Generated code is not a separate import but emitted by the codegen plugin
// plugin config in codegen.yml: plugins: - graphql-codegen-apollo-next-ssr
The plugin generates Apollo cache read/write functions. No direct import of the plugin's JS at runtime.
// Example generated symbols: readQuery, writeQuery, getServerSideProps functions
import { readUser, writeUser } from './generated/page'
import { readUser } from 'graphql-codegen-apollo-next-ssr'
Generated files are placed wherever you configure the codegen output.
// Using the plugin in codegen.yml
plugins: - graphql-codegen-apollo-next-ssr
plugins: - '@graphql-codegen/apollo-next-ssr'
The package is used as a codegen plugin, not imported in application code. The npm package name is exactly 'graphql-codegen-apollo-next-ssr'.

Configures graphql-codegen-apollo-next-ssr plugin in codegen.yml and uses generated getServerSideProps and HOC in a Next.js page.

// codegen.yml schema: 'schema.graphql' documents: './src/**/*.graphql' generates: ./src/generated/page.ts: config: documentMode: external importDocumentNodeExternallyFrom: ./graphql preset: import-types presetConfig: typesPath: ./graphql plugins: - graphql-codegen-apollo-next-ssr // Example usage in Next.js page import { getServerSidePropsUser, withUser } from '../generated/page'; // getServerSideProps export const getServerSideProps = getServerSidePropsUser; // Component export default withUser(MyComponent);
Debug
Known issues
deprecatedProject is looking for maintainer; consider using alternative swr-gql solution.
fix
Evaluate swr-gql (https://github.com/correttojs/swr-gql) as a replacement.
affects: >=1.0.0
gotchaPlugin requires peer dependency graphql < 17.0.0; may conflict with newer versions.
fix
Ensure graphql version is <17.0.0 in package.json.
affects: >=1.0.0
breakingGenerated code default import paths changed in v1.2.0 between Apollo Client v2 and v3.
fix
Set reactApolloVersion config to match your Apollo Client version (2 or 3).
affects: >=1.2.0
deprecatedwithHooks configuration option may be deprecated; documentation is sparse.
fix
Check generated output; if hooks not needed, set withHooks: false.
affects: >=1.0.0
gotchaCustom imports via customImports config must be valid TypeScript; errors only appear at build time.
fix
Use fully qualified imports or adjust tsconfig.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Plugin graphql-codegen-apollo-next-ssr not found
Plugin not installed or wrong name in codegen.yml
fix
npm install graphql-codegen-apollo-next-ssr --save-dev and ensure plugins list uses exact package name.
Cannot find module 'apollo-cache-inmemory'
apolloCacheImportFrom defaults to apollo-cache-inmemory which may not be installed (Apollo v3 uses @apollo/client)
fix
Set apolloCacheImportFrom to '@apollo/client' when using Apollo Client v3.
TypeError: Cannot read properties of undefined (reading 'kind')
Schema or documents not loaded properly; codegen fails to parse operations.
fix
Verify schema and document paths in codegen.yml; run graphql-codegen with verbose logging.
Plugin 'graphql-codegen-apollo-next-ssr' requires 'graphql' to be installed as a peer dependency
Missing graphql package or version mismatch (<17.0.0 required).
fix
Install graphql@^16.0.0 (or compatible <17) in your project.
Upgrade
Version history
1.7.4latest on npm
Audit
Dependencies
graphqloptionalpeer dependency — used for AST types
Agent activity
8 hits · last 30 days
node
8
Resources
graphql-codegen-apollo-next-ssr — npm install graphql-codegen-apollo-next-ssr · libregistry