# prismic-apollo-introspect

> Prismic introspection utility to generate fragment types for Apollo

Latest version **0.1.1** (published 2021-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install prismic-apollo-introspect
pnpm add prismic-apollo-introspect
yarn add prismic-apollo-introspect
bun add prismic-apollo-introspect
```

Provides the command `prismic-apollo-introspect`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-10-02 |
| First published | 2021-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 3 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Madeleine Ostoja |
| Maintainers | madeleineostoja |
| Keywords | prismic, apollo, introspect, fragment-types |

## Links

- npm: https://www.npmjs.com/package/prismic-apollo-introspect
- Repository: https://github.com/madeleineostoja/prismic-apollo-introspect
- Homepage: https://github.com/madeleineostoja/prismic-apollo-introspect#readme
- Issues: https://github.com/madeleineostoja/prismic-apollo-introspect/issues
- npm.io page: https://npm.io/package/prismic-apollo-introspect

## Dependencies (3)

- [commander](https://npm.io/package/commander.md) ^7.2.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1
- [log-symbols](https://npm.io/package/log-symbols.md) ^5.0.0

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-10-02
- 0.1.0 — 2021-05-24

## README

# Prismic Apollo Introspect

[![NPM](https://img.shields.io/npm/v/prismic-apollo-introspect)](https://www.npmjs.com/package/prismic-apollo-introspect) [![License](https://img.shields.io/npm/l/prismic-apollo-introspect)](https://github.com/madeleineostoja/prismic-apollo-introspect/blob/master/LICENSE.md)

Utility for automatically generating [Prismic fragment types needed for Apollo](https://prismic.io/docs/technologies/introspection-fragment-matching-with-graphql). Without providing introspection fragment matching to Apollo with Prismic, you won't be able to infer Prismic slice fragments.

## Usage

```sh
npm i prismic-apollo-introspect
```

Run the cli utility, providing your Prismic repo ID and the full path to the generated fragment types JSON file, which you'll pass to Apollo's `IntrospectionFragmentMatcher`.

```sh
prismic-apollo-introspect --repo <repoId> --out <path>
```

Once you've run the utility, pass your generated fragment types to Apollo

```js
import { PrismicLink } from 'apollo-link-prismic';
import {
  InMemoryCache,
  IntrospectionFragmentMatcher,
} from 'apollo-cache-inmemory';
import Apollo from 'apollo-client';
import fragmentTypes from '<path-to-generated-fragment-types>';

const prismicApi = 'https://your-repo-name.cdn.prismic.io/graphql';

export const client = new Apollo({
  link: PrismicLink({ uri: prismicApi }),
  cache: new InMemoryCache({
    fragmentMatcher: new IntrospectionFragmentMatcher({
      introspectionQueryResultData: fragmentTypes,
    }),
  }),
});
```

You should re-run the introspection generator every time your content model changes, to make it easier you can automatically run it in a `pre` npm script to your development script, which will run every time you run develop.

```json
{
  "scripts": {
    "predevelop": "prismic-apollo-introspect --repo <repoId> --out <path>",
    "develop": "..."
  }
}
```

## Private repos

If your Prismic repo requires an access token, set a `PRISMIC_TOKEN` environment variable. The utility will use it to connect to your repo.

Eg:

```sh
PRISMIC_TOKEN=XXXX prismic-apollo-introspect --repo <repoId> --out <path>
```

---
_Source: https://npm.io/package/prismic-apollo-introspect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
