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
Along with what is supported by the parent tech stack (.nodejs.tech.stack
), the following are overridden and additional capabilities:
- The macros and templates resulting in
- instantiating and starting the Apollo server
- initiating the Datastore
- table and pagination definitions
- the queries, schemas, resolvers, and data source declarations
||secret credentials to communicate with an Apollo server instance
||Size of page for pagination
||include a client directive
||Utilize the built-in cache
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:
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:
Running the Apollo Server
Issue the following command to start the Apollo GraphQL server, listening on default port _4000_.
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:
To learn how to issue queries using GraphQL, click here