es-dev-server-import-graphql
v2.1.0
Published
An es-dev-server response transformer for importing GraphQL files
Downloads
9
Readme
es-dev-server-import-graphql
Import GraphQL into your modules serve them with es-dev-server
Usage
es-dev-server.config.js
const graphql = require('es-dev-server-import-graphql');
module.exports = {
port: 8080,
watch: true,
nodeResolve: true,
appIndex: 'demo/index.html',
moduleDirs: ['node_modules', 'web_modules'],
plugins: [
graphql()
],
};
index.js
import MoodQuery from './Mood.query.graphql';
import { ApolloQuery, customElement, html } from '@apollo-elements/lit-apollo';
interface Data {
mood: string;
}
@customElement('mood-query')
export class MoodQuery extends ApolloQuery<Data, null> {
query = MoodQuery
render() {
return (
this.error ? html`<p>Error is ${this.error}</p>`
: this.data ? html`<p>Mood is ${this.data.mood}</p>`
: ''
);
}
}
Mood.query.json
query MoodQuery {
mood
}