Registry / devops / graphql-fragments

graphql-fragments

JSON →
library0.1.0jsnpmunverified

A lightweight library (v0.1.0) providing utility functions to compose, transform, and manage GraphQL fragments, originally designed for use with Relay and Apollo. Since v0.1.0 is an early release with limited adoption, it is recommended to check more active alternatives like graphql-anywhere or fragment utilities in Apollo Client. No known release cadence; key differentiator is fragment composition helpers.

npm install graphql-fragments
INSTALL
IMPORT
SIG · GRAPHQL-FRAGMENTS
G
graphql-fragments
devopsjavascriptv0.1.0
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.

default
import fragments from 'graphql-fragments'
const fragments = require('graphql-fragments')
ESM-only; CommonJS require will fail as package only ships ES modules.
composeFragments
import { composeFragments } from 'graphql-fragments'
import { composeFragments } from 'graphql-fragments/lib/compose'
Direct path to file not supported; only top-level exports.
FragmentMap
import type { FragmentMap } from 'graphql-fragments'
import { FragmentMap } from 'graphql-fragments'
FragmentMap is a type only export; use type import to avoid runtime errors.

Shows how to compose multiple GraphQL fragments into one string using composeFragments.

import { composeFragments } from 'graphql-fragments'; const userFragment = ` fragment UserFields on User { id name } `; const addressFragment = ` fragment AddressFields on User { address { city zip } } `; const merged = composeFragments([userFragment, addressFragment]); console.log(merged); // Output: merged fragment string
Debug
Known issues
deprecatedPackage is no longer maintained and may not work with newer GraphQL or Apollo versions.
fix
Migrate to graphql-anywhere or use Apollo Client's fragment utilities.
affects: >=0.0.0
gotchaComposed fragments do not deduplicate fields or handle fragment references (spreads).
fix
Manually ensure fragments are compatible or use a more robust fragment composition tool.
affects: 0.1.0
breakingChanging import paths or export structure in future versions would break ESM imports.
fix
Always import from top-level package, not subpaths.
affects: 0.1.0
Errors
Common errors & fixes
Cannot find module 'graphql-fragments'
Package is not installed or only ships ES modules without proper resolution in Node.js < 12.
fix
Install package: npm install graphql-fragments. If using Node < 12, use ESM support via --experimental-modules flag or upgrade Node.
composeFragments is not a function
Incorrect import (e.g., using require instead of import) or wrong export name.
fix
Use: import { composeFragments } from 'graphql-fragments';
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
graphql-fragments — npm install graphql-fragments · libregistry