Registry / testing / graphql-ast-types-browser

graphql-ast-types-browser

JSON →
library1.0.2jsnpmunverified

A temporary clone of graphql-ast-types for browser environments, providing autogenerated helper functions to build and validate GraphQL AST nodes. This version (1.0.2) requires graphql ^0.11.7 and offers functions like document, operationDefinition, field, name, and is/assert helpers. It is a maintenance-only fork intended to be deleted once the upstream issue is resolved. Use at your own risk.

npm install graphql-ast-types-browser
INSTALL
IMPORT
SIG · GRAPHQL-AST-TYPES-
G
graphql-ast-types-browser
testingjavascriptv1.0.2
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.

t
import * as t from 'graphql-ast-types-browser'
import t from 'graphql-ast-types-browser'
Only namespace import works; default import is not available.
document
const { document } = require('graphql-ast-types-browser')
import document from 'graphql-ast-types-browser'
CommonJS destructuring works; default import not supported.
isName
import { isName } from 'graphql-ast-types-browser'
Named exports are available.

Shows how to build a GraphQL AST using namespace import and print it, plus usage of is/assert helpers.

import * as t from 'graphql-ast-types-browser'; import { print } from 'graphql/language'; const ast = t.document([ t.operationDefinition( 'query', t.selectionSet([ t.field(t.name('foo')), t.field(t.name('bar')) ]) ) ]); console.log(print(ast)); // query { // foo // bar // } // Validation helpers console.log(t.isName(t.name('Hello'))); // true console.log(t.isName({ kind: 'Name' })); // true console.log(t.assert({ kind: 'Name' })); // no error console.log(t.isName({ kind: 'IntValue' })); // false
Debug
Known issues
deprecatedThis package is a temporary clone and will be deleted. Use the original graphql-ast-types package instead.
fix
Switch to 'graphql-ast-types' (note: requires graphql ^0.11.7).
affects: all
breakingRequires graphql ^0.11.7; incompatible with newer graphql versions.
fix
Use a compatible graphql version or consider migrating to graphql-tag or other modern tools.
affects: >=1.0.0
gotchaCannot use default import; must use namespace import (import * as t) or CommonJS destructuring.
fix
Use `import * as t from 'graphql-ast-types-browser'` or `const { document } = require('graphql-ast-types-browser')`.
affects: all
Errors
Common errors & fixes
Cannot find module 'graphql-ast-types-browser'
Package not installed or name misspelled.
fix
Run `npm install graphql-ast-types-browser` and ensure correct import path.
'document' is not exported from 'graphql-ast-types-browser'
Using named import instead of namespace import.
fix
Use `import { document } from 'graphql-ast-types-browser'` instead of `import { document } from 'graphql-ast-types-browser'`
TypeError: Cannot read properties of undefined (reading 'document')
Using default import which is not defined.
fix
Use `import * as t from 'graphql-ast-types-browser'` then `t.document(...)`.
graphql: Peer dependency not found
graphql package is missing or wrong version.
fix
Install graphql@^0.11.7: `npm install graphql@0.11.7`.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency for graphql AST types
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-ast-types-browser — npm install graphql-ast-types-browser · libregistry