Stack Name - Apollo GraphQL

Synopsis

The is the base reusable implementation for Apollo GraphQL type tech stacks.  This implementation is headless (no UI), serving as a set of query-based APIs to manipulate a model.  This tech stack generates the necessary UI components for both React or AngularJS to use the Apollo Query Client.  This client allows for the testing of the generated backend using GraphQL (Graph Query Language) The stack includes:
  • GraphQL implementation using Apollo GraphQL Server
  • Default persistence use SQLite with Sequelize for object to relational mapping

Details

Author dev@harbormaster.ai
Access Public
Derived From .nodejs.tech.stack
Long Name Apollo GraphQL
Short Name Apollo
Language(s) Javascript, Typescript, HTML, YAML, XML, Velocity Macros
Git Url https://github.com/Harbormaster-AI/techstacks/tree/main/Apollo
Example Project YAML https://github.com/Harbormaster-AI/cli/blob/main/samples/yamls/project.as.code/apollo-project-as-code.yml

Contents

Along with what is supported by the parent  tech stack (.nodejs.tech.stack), the following are overridden and additional capabilities:

Options

Option Name description Type values
apollo
service input
engine-api-key secret credentials to communicate with an Apollo server instance input
pageSize Size of page for pagination input default: 20
clientType client type select
  • react
  • angular
ec2-includeClient include a client directive boolean default: true
cacheInMemory Utilize the built-in cache boolean default: true

Usage

If using a CI/CD platform such as CircleCI, AWS Codebuild, Jenkins, etc.., it is best to refer to the Pipeline YAML file generated for that platform. If not using a CI/CD platform refer to the instructions below on how to use the generated project.

To get started manually

The following instructions assume NPM is installed. If not, you can download it by installing Node.js.

Create an Apollo Account

In order to use the Apollo GraphQL Server, first create an account at https://www.apollographql.com/ .

Create a New Service

You next have to create a service within your account. When the service is created, you will be provided with an Apollo Engine API key of the form:
 _service:xxxxxxxxxx-9999:uygR3DDPKQ8EsexaUaPfVg_.
You will need to provide this the engine-api-key input parameter to Harbormaster in order for it to be applied within the generated application files. Also, apply the name of the service as another input parameter. This is the text between the 2 colons (:) of the the engine-api-key

Install the application

Once the application files have been pulled (or cloned) from your Git repository, cd (change directory) to the application directory. This directory will be named as the application name provided as part of the input parameters. From this directory, install the app dependencies by running the following command:
`npm install`

Running the Apollo Server

Issue the following command to start the Apollo GraphQL server, listening on default port _4000_.
npm start

Publish the Generated Schema

From another process and once the Apollo server has completed startup, push the generated schema to the Apollo registry:
npx apollo service:push --endpoint=http://localhost:4000

Test Generated GraphQL API

Run the Apollo Client from your browser:
http://localhost:4000
To learn how to issue queries using GraphQL, click here.