easy way to import and parse graphql files in deno
install using Trex package manager
$ trex install --map importql
or use url
import { importQL } from "https://deno.land/x/importql/mod.ts";
# query.graphql file
type User {
firstName: String
lastName: String
}
input UserInput {
firstName: String
lastName: String
}
type ResolveType {
done: Boolean
}
type Query {
getUser(id: String): User
}
type Mutation {
setUser(input: UserInput!): ResolveType!
}
import { importQL } from "https://deno.land/x/importql/mod.ts";
const query = importQL("query.graphql"); // import the .graphql file
// query is now a GraphQL syntax tree object.
// {
// "kind": "Document",
// "definitions": [
// {
// "kind": "OperationDefinition",
// "operation": "query",
// "name": null,
// "variableDefinitions": null,
// "directives": [],
// "selectionSet": {
// "kind": "SelectionSet",
// "selections": [
// {
// "kind": "Field",
// "alias": null,
// "name": {
// "kind": "Name",
// "value": "user",
// ...
- --allow-read