@ejez/quasar-app-extension-graphql

0.2.2 • Public • Published

Quasar GraphQL App Extension

Introduction

This app extension adds graphql support to your quasar projects.

It uses Apollo GraphQL and its vue plugin Vue Apollo

Server side rendering (SSR) mode is supported by this extension.

Using this extension is the easy way to add GraphQL support, but if you wish to have full control of the graphql integration code, you can opt for a manual setup described here: github.com/ejez/quasargraphql

Installation

quasar ext add @ejez/graphql

Quasar CLI will retrieve the extension from NPM (@ejez/quasar-app-extension-graphql)

Note: Some code will be added to the html template file of your app (src/index.template.html)

Prompts

You will be prompted to enter the URI of your GraphQL endpoint. You can skip this and instead provide the URI using an env variable when running quasar:

GRAPHQL_URI=https://prod.example.com/graphql quasar build
GRAPHQL_URI=https://dev.example.com/graphql quasar dev

If you don't have a GraphQL endpoint yet, you can create one at FakeQL to experiment with.

Uninstall

quasar ext remove @ejez/graphql

Note: The added code to the html template file (src/index.template.html) will be removed.

Usage

Check the guide in Vue Apollo docs

Example usage:

<template>
  <div>
    <!-- when the query response is not received yet, data from it is undefined,
    so we need to use v-if -->
    <div v-if="post">
      GraphQL query result:<br>{{ post.title }}
    </div>
    <div v-else>
      loading...
    </div>
  </div>
</template>

<script>
import gql from 'graphql-tag'

export default {
  // https://apollo.vuejs.org/guide/apollo/#usage-in-vue-components
  apollo: {
    post: {
      query: gql`query {
        post(id: 5) {
          title
        }
      }`
    }
  }
}
</script>

Readme

Keywords

none

Package Sidebar

Install

npm i @ejez/quasar-app-extension-graphql

Weekly Downloads

2

Version

0.2.2

License

MIT

Unpacked Size

11.2 kB

Total Files

12

Last publish

Collaborators

  • ejez