Skip to content

Higher order Next.js config to generate GraphQL fragment types for Apollo

License

Notifications You must be signed in to change notification settings

cansin/next-with-apollo-possible-types

Repository files navigation

next-with-apollo-possible-types

tests codeql size dependencies downloads license

Higher order Next.js config to generate GraphQL fragment types for Apollo (as described at https://www.apollographql.com/docs/react/data/fragments/#generating-possibletypes-automatically.

Install

yarn add next-with-apollo-possible-types

Basic Usage

Update or create next.config.js with

const withPossibleTypes = require("next-with-apollo-possible-types");

module.exports = withPossibleTypes({
  possibleTypes: {
    gqlUrl: "http://localhost:8000/graphql",
  },
  // .
  // ..
  // ... other Next.js config
});

Add possibleTypes.json to your .gitignore

possibleTypes.json

Configuration

There are options you can use to customize the behavior of this plugin by adding possibleTypes object in the Next.js config in next.config.js.

const withPossibleTypes = require("next-with-apollo-possible-types");

module.exports = withPossibleTypes({
  possibleTypes: {
    gqlUrl: "https://www.example.com/graphql",
    output: "./path/to/possibleTypes.json"
  },
});

Available Options

  • gqlUrl: string - the GraphQL endpoint URL.
    • defaults to /graphql.
  • output: string - The file path of the Fragment types JSON to be created.
    • defaults to ./possibleTypes.json.

About

Higher order Next.js config to generate GraphQL fragment types for Apollo

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published