app-extension-apollo

Statements | Branches | Functions | Lines |
---|
 |  |  |  |
This is the official Quasar App-Extension for adding GraphQL to your Quasar project.
Introduction
This app extension adds GraphQL support to your Quasar projects.
It uses Apollo Client and the Vue Apollo plugin.
Server side rendering (SSR) mode is also supported by this extension.
Installation
quasar ext add @m8a/apollo
Quasar CLI will retrieve the extension from NPM (@m8a/quasar-app-extension-apollo)
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 environment 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 to experiment with at FakeQL or other similar services.
Uninstall
quasar ext remove @m8a/apollo
Note: The added code to the html template file (src/index.template.html
) will be removed.
Warning Added directory src/quasar-app-extension-apollo
will be removed, if you need, make a backup before uninstalling the extension.
Configuration
Apollo client can be configured through src/quasar-app-extension-apollo/apollo-client-config.js
Usage
Check the guide in Vue Apollo docs
Example usage:
src/pages/Index.vue
<template>
<q-page>
<div v-if="post">
GraphQL query result:<br>{{ post.title }}
</div>
<div v-else>
loading...
</div>
</q-page>
</template>
<script>
import gql from 'graphql-tag'
export default {
name: 'PageIndex',
apollo: {
post: {
query: gql`query {
post(id: 5) {
title
}
}`
}
}
}
</script>
Further Development Requirements
Base Requirements
Nice to Have