@awardit/rollup-plugin-graphql-ast-import
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Rollup Plugin GraphQL AST Import

Rollup plugin enabling imports of operations as AST from .graphql files.

Installation

npm i -S rollup-plugin-graphql-ast-import

Usage

// rollup.config.js
import { graphql } from "rollup-plugin-graphql-ast-import";

export default {
  // ...
  plugins: [graphql()],
};
# myqueries.graphql:
query films {
  allFilms {
    title
    releaseDate
    characters {
      name
    }
  }
}

query filmsWithPerson($name: String!) {
  Person(name: $name) {
    films {
      title
      releaseDate
    }
  }
}
// myfile.js
import { films, filmsWithPerson } from "./myqueries.graphql";
import { client } from "./ast-consuming-graphql-client";

const {
  data: {
    Person: { Films: filmsWithLuke },
  },
} = await client(filmsWithPerson, { name: "Luke Skywalker" });

console.log("Films with Luke Skywalker: ", filmsWithLuke);

const {
  data: { allFilms },
} = await client(films);

console.log("All films", allFilms);

Package Sidebar

Install

npm i @awardit/rollup-plugin-graphql-ast-import

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

8.42 kB

Total Files

6

Last publish

Collaborators

  • m4rw3r
  • lokecarlsson
  • poggen