@graphitation/supermassive-ast
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@graphitation/supermassive-ast

AST definitions and AST transform for supermassive. Annotates a document so a supermassive can execute it without runtime schema.

Transform

addTypesToRequestDocument converts untyped graphql-js AST node into a Supermassive typed one.

function addTypesToRequestDocument(
  schema: GraphQLSchema,
  document: TypelessAST.DocumentNode
): TypedAST.DocumentNode

With @graphitation/graphql-js-tag and @graphitation/ts-transform-graphql-js-tag (in webpack config)

import { buildASTSchema } from 'graphql'
import { getTransformer } from "@graphitation/ts-transform-graphql-js-tag";
import { annotateDocumentGraphQLTransform } from "@graphitation/supermassive";

// ...

{
  test: /\.tsx?$/,
  loader: "ts-loader",
  options: {
    getCustomTransformers: () => ({
       before: [
          getTransformer({
            graphqlTagModuleExport: "graphql",
            transformer: annotateDocumentGraphQLTransform(
              buildASTSchema({
                fs.readFileSync(
                  "PATH_TO_SCHEMA_TYPEDEFS.graphql",
                  { encoding: "utf-8" }
                ),
              )
            ),
          }),
        ],
      }),
    },
  },
}

Readme

Keywords

none

Package Sidebar

Install

npm i @graphitation/supermassive-ast

Weekly Downloads

40

Version

2.0.0

License

MIT

Unpacked Size

84.8 kB

Total Files

28

Last publish

Collaborators

  • kerrynf
  • freiksenet
  • alloy
  • kenotron_msft
  • gql-svc