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

Authordev@harbormaster.ai
AccessPublic
Derived From.nodejs.tech.stack
Long NameApollo GraphQL
Short NameApollo
Language(s)Javascript, Typescript, HTML, YAML, XML, Velocity Macros
Git Urlhttps://github.com/Harbormaster-AI/techstacks/tree/main/Apollo
Example Project YAMLhttps://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 NamedescriptionTypevalues
apollo
service input 
engine-api-keysecret credentials to communicate with an Apollo server instanceinput 
pageSizeSize of page for paginationinputdefault: 20
clientTypeclient typeselect
  • react
  • angular
ec2-includeClientinclude a client directivebooleandefault: true
cacheInMemoryUtilize the built-in cachebooleandefault: 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.