Socket
Book a DemoInstallSign in
Socket

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

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

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

latest
npmnpm
Version
1.0.1
Version published
Maintainers
3
Created
Source

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);

Keywords

rollup-plugin

FAQs

Package last updated on 27 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts