Skip to content

Latest commit

History

History

basic

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

angulars-fullstack-apollo-basic

馃殌 Basic starter code for a fullstack app based on Angular, GraphQL & Apollo Client.

TODO

Technologies

  • Frontend
    • Angular: Frontend framework for building mobile and desktop web applications
    • Apollo Client: Fully-featured, production ready caching GraphQL client
  • Backend
    • Graphcool: Powerful GraphQL database
    • graphql-yoga: Fully-featured GraphQL server with focus on easy setup, performance & great developer experience
    • graphcool-binding: GraphQL binding for Graphcool services

Requirements

You need to have the following things installed:

  • Node 8+
  • Graphcool CLI: npm i -g graphcool@beta
  • GraphQL CLI: npm i -g graphql-cli
  • GraphQL Playground desktop app (optional): Download

Preview

Getting started

# Bootstrap GraphQL server in directory `my-app`, based on `angular-fullstack-basic` boilerplate
graphql create my-app --boilerplate angular-fullstack-basic

# Navigate into the new project's `server` directory
cd my-app/server

# Deploy the Graphcool database & start the server (runs on http://localhost:4000)
yarn start

# Navigate back into the project's root directory and launch the Angular app
cd ..
yarn start # open http://localhost:3000 in your browser
Alternative: Clone repo
TODO

Docs

Project structure

/server

/server/database

  • database/datamodel.graphql contains the data model that you define for the project (written in SDL).
  • database/schema.generated.graphql defines the database schema. It contains the definition of the CRUD API for the types in your data model and is generated based on your datamodel.graphql. You should never edit this file manually, but introduce changes only by altering datamodel.graphql and run graphcool deploy.

/server/src

  • src/schema.graphql defines your application schema. It contains the GraphQL API that you want to expose to your client applications.
  • src/index.js is the entry point of your server, pulling everything together and starting the GraphQLServer from graphql-yoga.

Common questions

I'm getting a 'Schema could not be fetched.' error after deploying, what gives?

Access to the Graphcool API is secured by a secret. This also applies to the introspection query. Using the latest version of GraphQL Playground, the Authorization header should automatically be setup with a proper JWT signing the secret. If that's not the case, you can follow these steps to access your API:

  1. Visit http://jwtbuilder.jamiekurtz.com/
  2. Replace the Key at the bottom of the page with your secret from the graphcool.yml
  3. Click Create signed JWT and copy the obtained token
  4. Now, to access the schema, use the Authorization: Bearer <token> header, or in the GraphQL Playground set it as JSON:
    {
      "Authorization": "Bearer <token>"
    }
  5. Reload the schema in the Playground (the refresh-button is located right next to the URL of the server)

Note: Currently, no content of the signed JWT is verified by the database! This will be implemented according to this proposal at a later stage.

Contributing

Your feedback is very helpful, please share your opinion and thoughts! If you have any questions, join the #graphql-boilerplate channel on our Slack.