Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cansin/next-with-apollo-possible-types
Higher order Next.js config to generate GraphQL fragment types for Apollo
https://github.com/cansin/next-with-apollo-possible-types
Last synced: about 2 months ago
JSON representation
Higher order Next.js config to generate GraphQL fragment types for Apollo
- Host: GitHub
- URL: https://github.com/cansin/next-with-apollo-possible-types
- Owner: cansin
- License: mit
- Created: 2020-08-19T21:22:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T01:20:34.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T02:16:42.432Z (3 months ago)
- Language: JavaScript
- Size: 1.6 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# next-with-apollo-possible-types
[![tests](https://github.com/cansin/next-with-apollo-possible-types/actions/workflows/tests.yml/badge.svg)](https://github.com/cansin/next-with-apollo-possible-types/actions/workflows/tests.yml)
[![codeql](https://github.com/cansin/next-with-apollo-possible-types/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/cansin/next-with-apollo-possible-types/actions/workflows/codeql-analysis.yml)
[![size](https://img.shields.io/bundlephobia/minzip/next-with-apollo-possible-types)](https://bundlephobia.com/result?p=next-with-apollo-possible-types)
[![dependencies](https://img.shields.io/librariesio/release/npm/next-with-apollo-possible-types)](https://libraries.io/npm/next-with-apollo-possible-types)
[![downloads](https://img.shields.io/npm/dm/next-with-apollo-possible-types)](https://www.npmjs.com/package/next-with-apollo-possible-types)
[![license](https://img.shields.io/github/license/cansin/next-with-apollo-possible-types)](https://github.com/cansin/next-with-apollo-possible-types/blob/master/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](https://www.apollographql.com/docs/react/data/fragments/#generating-possibletypes-automatically]).## Install
```bash
yarn add next-with-apollo-possible-types
```## Basic Usage
Update or create `next.config.js` with
```js
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`
```git
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`.```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`.