• Stars
    star
    119
  • Rank 287,166 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create Apollo App is a command-line tool designed to generate fully-configured starter Apollo GraphQL projects with essential dependencies for developing web, server and mobile applications and zero build configuration.

Create Apollo App

Join the chat at https://gitter.im/sysgears/create-apollo-app npm version Twitter Follow

Description

Create Apollo App is a command-line tool that generates a fully configured starter Apollo (GraphQL) project with only essential dependencies. With Create Apollo App, you can start developing a client, server, or mobile app, or a universal application in no time.

The projects generated with Create Apollo App are built of familiar technologies from the JavaScript ecosystem: TypeScript, Webpack, React, Express, and React Native. Depending on the type of the project you want to develop, the mentioned technologies are used in different combinations to provide particular setups for server, client, or mobile development.

Create Apollo App relieves you from the pain of installing and configuring an Apollo project while making it easy to change project configurations if necessary.

Generating a Project with Create Apollo App

Prerequisites

Install the following dependencies:

  • Node.js 6.x or higher (Node.js 8.x is recommended)
  • NPM or Yarn to manage JavaScript packages and run scripts

Besides the dependencies for Node.js, you may also need to install and set up additional tools for mobile development:

  • iOS Simulator or Android emulation software
  • Xcode (optional; an IDE for iOS development)
  • Android Studio (optional; an IDE for Android development)

Installing Expo Client is also optional. If you set up iOS Simulator or a similar tool, Create Apollo App will automatically download Expo Client if it's not installed.

Generating a Project

Start a new project with Create Apollo App using the following command (the default NPM utility is used):

npx create-apollo-app new-apollo-app

If youโ€™re using Yarn, run:

yarn create apollo-app my-app

yarn create will automatically prefix apollo-app with create-. For more information, you can consult this blog post on Yarn.

From this point onward, we'll use Yarn in our examples for running the project.

During installation, the terminal will prompt the following six options:

โฏ @server-web: TypeScript, Apollo (GraphQL), Express server, React for web
  @server-mobile: TypeScript, Apollo (GraphQL), Express server, React Native for mobile
  @universal: TypeScript, Apollo (GraphQL), Express server, React for web, React Native for mobile
  @server: TypeScript, Apollo (GraphQL), Express server
  @web: TypeScript, Apollo (GraphQL), React web app
  @mobile: TypeScript, Apollo (GraphQL), React Native for mobile

You can select the necessary project template using the arrow keys on your keyboard. Alternatively, you can start typing the name of the template to filter the list.

You can also specify the name of the template by attaching the @name_of_the_template after the project name, for example:

yarn create apollo-app my-app@web

If you run the command above, Create Apollo App will create a my-app/ project directory with the @web template meaning the client-side Apollo app. Similarly, add @server-web, @universal, or other template name instead of @web to choose a particular template.

Consult the Apollo Project Templates section to know what templates are currently available.

Select the first (default) option @server-web from the list and press Enter. Create Apollo App will generate a client-server application.

Note that it may take a while (usually up to a minute) for all dependencies to be installed and for the project to be configured. The terminal will confirm when the project is ready.

Running the Project in Development Mode

Once the installation is complete, run:

cd my-app
yarn start

A development build will be generated. You can start changing the source code in the project files located in the packages/server/src/ and packages/web/src/ directories.

NOTE: If you want to add CSS, SCSS, Sass, or Less to the frontend React application, you need to add the PostCSS configuration file postcss.config.js under the {app-root}/src for the @web template or the {app-root}/packages/web/src folder for the @server-web and @universal templates.

The PostCSS configuration file can be empty, like this:

module.exports = {};

The client-side application will be automatically opened in your default browser at http://localhost:3000. The server-side GraphQL application runs on http://localhost:8080.

If you installed a template for mobile development, the React Native app will be opened at http://localhost:3020 for iOS and at http://localhost:3010 for Android.

Generating the Production-Ready Code

If you want to build a production version of the app (i.e., the code will be minified), run:

yarn build

The production-ready code will be saved to packages/server/build/ and packages/web/build/ directories for server-side and client-side code respectively.

Apollo Project Templates

Create Apollo App provides you with the default configurations for different kinds of projects. For example, if you need to build only a client-side application, you can select a respective template โ€“ @web โ€“ during installation.

Overall, you can choose one of the six templates:

  • @web for a client-side application.
  • @server for a server-side application.
  • @mobile for a mobile application.
  • @server-web โ€“ (default) a complete solution for building a client-server app.
  • @server-mobile โ€“ a complete solution for building a server-side app and mobile front end.
  • @universal โ€“ the most comprehensive solution for building an app for the client, server, and mobile.

Project Structure

We'll review the structure of the @universal project, meaning it will have the client/, server/, and mobile/ packages under the packages/ directory. The @server-web template that you installed comes without the mobile package.

Here's an overview of the @universal project structure:

my-apollo-app
โ”œโ”€โ”€ node_modules/
โ”œโ”€โ”€ packages/
    โ”œโ”€โ”€ mobile
        โ”œโ”€โ”€ node_modules/
        โ”œโ”€โ”€ src/
            โ”œโ”€โ”€ App.tsx
            โ”œโ”€โ”€ AwakeInDevApp.js
            โ””โ”€โ”€ index.ts
        โ”œโ”€โ”€ typings/
        โ”œโ”€โ”€ app.json
        โ”œโ”€โ”€ package.json
        โ”œโ”€โ”€ tsconfig.json
        โ””โ”€โ”€ tslint.json        
    โ”œโ”€โ”€ server/
        โ”œโ”€โ”€ node_modules/
        โ”œโ”€โ”€ src/
            โ”œโ”€โ”€ index.ts
            โ”œโ”€โ”€ resolvers.ts
            โ”œโ”€โ”€ schema.graphql
            โ”œโ”€โ”€ schema.ts
            โ””โ”€โ”€ server.ts
        โ”œโ”€โ”€ typings/
        โ”œโ”€โ”€ package.json
        โ”œโ”€โ”€ tsconfig.json
        โ””โ”€โ”€ tslint.json
    โ””โ”€โ”€ web/
        โ”œโ”€โ”€ src/
            โ”œโ”€โ”€ App.tsx
            โ””โ”€โ”€ index.tsx
        โ”œโ”€โ”€ typings/
        โ”œโ”€โ”€ package.json
        โ”œโ”€โ”€ tsconfig.json
        โ””โ”€โ”€ tslint.json
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tslint.json
โ””โ”€โ”€ yarn.lock

You'll work with the files located in packages/mobile/src/, packages/server/src, and packages/web/src/ when working on your Apollo project. In those directories, you can view the default project files, which you may freely change or delete.

License

Copyright ยฉ 2018 SysGears Limited. This source code is licensed under the MIT license.

More Repositories

1

apollo-universal-starter-kit

Apollo Universal Starter Kit is a SEO-friendly, fully-configured, modular starter application that helps developers to streamline web, server, and mobile development with cutting-edge technologies and ultimate code reuse.
JavaScript
1,683
star
2

webpack-virtual-modules

Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.
TypeScript
494
star
3

mochapack

Mocha test runner with integrated webpack precompiler
TypeScript
184
star
4

grain

Grain is a lightweight and powerful static website generator with custom themes to help create static, SEO-friendly websites or a blog in no time.
Groovy
157
star
5

spinjs

SpinJS is now Zen! The project has been renamed and moved to Larix Framework.
TypeScript
43
star
6

selenium-automation-bundle

Selenium Automation Bundle is an extendable and adaptable solution that simplifies automated testing to help focus on writing tests with Selenide and TestNG using the best test design patterns.
Groovy
39
star
7

persistgraphql-webpack-plugin

PersistGraphQL Webpack Plugin
JavaScript
37
star
8

react-apollo-express-example

Example of Express, React, and Apollo application. Let's have a look on our blog to read in-depth tutorial on how to create your own! https://sysgears.com/articles/how-to-create-an-apollo-react-express-application/
JavaScript
25
star
9

domain-schema

Domain Driven Design Schema for JavaScript
JavaScript
22
star
10

apollo-logger

Apollo GraphQL Logger
TypeScript
19
star
11

pinyarn

pins Yarn to a specific version and downloads it automatically on demand
JavaScript
16
star
12

larix

Larix Meta Framework - a polyglot ecosystem for creating modular software with trivially addable and removable feature modules
TypeScript
15
star
13

grain-theme-portfolio

Grain Bootstrap Theme Stylish Portfolio
CSS
14
star
14

grain-theme-octopress

Octopress Grain Theme
CSS
13
star
15

scala-graphql-api-example

Scala
13
star
16

grain-theme-template

Template for new Grain themes
Groovy
12
star
17

java-berkleydb-queue

Lightweight fast persistent queue in Java using Berkley DB
Java
12
star
18

grain-theme-freelancer

Grain Bootstrap Theme Freelancer
CSS
11
star
19

grain-theme-agency

Grain Bootstrap Theme Agency
CSS
11
star
20

akka-spark-pipeline

An example project that implements a data pipeline using Scala, Akka, and Spark and works with document-oriented and graph databases to let you find out how frequently a specific technology is used with different technology stacks.
Scala
11
star
21

grain-theme-business

HTML
9
star
22

glace-dynamic-web-flow

Glace Dynamic Web Flow plugin
Groovy
9
star
23

scala-akka-graphql-kit

Scala starter kit for GraphQL applications
Scala
8
star
24

react-infinite-scroll-example

In your React application, you may need to implement infinite scroll pagination with Apollo. Here it is an example. And we explain how you can achieve this in your application using `apollo-link-state` in this publication: https://sysgears.com/articles/how-to-create-an-apollo-react-express-application/
JavaScript
8
star
25

glace-dynamic-web-flow-showcase

Glace Dynamic Web Flow plugin showcase
Groovy
7
star
26

grain-gradle-plugin

Gradle plugin for Grain
Groovy
7
star
27

apollo-cache-router

Apollo GraphQL Cache Router
TypeScript
7
star
28

apollo-cache-logger

Apollo Cache Logger
TypeScript
6
star
29

auth-with-play-silhouette-example

Scala
5
star
30

graphql-java-starter-kit

GraphQL Java Starter Kit โ€” GraphQL Java app boilerplate for Server with React JavaScript code for Mobile and Web, stack: Java, Spring, Apollo, GraphQL, React 16, React Native, Expo, Express, SQLite, Twitter Bootstrap, Babel, Webpack
JavaScript
5
star
31

scala-spark-test-utils

5
star
32

scala-graphql-error-handling-example

Scala
4
star
33

graphql-codegen-webpack-plugin

Webpack Plugin for graphql-code-generator
TypeScript
4
star
34

grain-theme-clean-blog

Grain Bootstrap Theme Clean Blog
CSS
2
star
35

scala-graphql-subscriptions-on-websockets

Scala
2
star
36

amplify-app

Toolkit to create AWS Amplify apps even faster
TypeScript
2
star
37

restapp

RestApp is an SEO-friendly, fully-configured, modular starter application that helps developers to streamline web, server, and mobile development with cutting-edge technologies and ultimate code reuse.
JavaScript
2
star
38

fractal-objects

Fractal Objects - self-similar objects that can be multiplied together and the result will be a fractal object and have the same type and shape as multiplicands.
TypeScript
2
star
39

node-hmr-plugin

Webpack plugin for running node process in development mode with HMR
JavaScript
1
star
40

hoister

General purpose node_modules hoister
TypeScript
1
star
41

react-router-redux

JavaScript
1
star
42

scala-tapir-akka-http-example

Scala
1
star
43

grain-theme-sphinx

Grain Sphinx Theme
JavaScript
1
star