All Projects → gatsbyjs → Api.gatsbyjs.org

gatsbyjs / Api.gatsbyjs.org

The API for the Gatsby swag store.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Api.gatsbyjs.org

Jamstack Serverless
Learn JAMstack Serverless Modern App Development in Baby Steps using Gatsby.js, React, TypeScript, GraphQL, Contentful, Netlify, FaunaDB, MongoDB, Apollo, Github Actions, Project Fugu, and CSS Houdini.
Stars: ✭ 178 (+304.55%)
Mutual labels:  graphql, apollo-server, serverless
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (+1097.73%)
Mutual labels:  graphql, apollo-server
Aws Appsync Chat
Real-Time Offline Ready Chat App written with GraphQL, AWS AppSync, & AWS Amplify
Stars: ✭ 522 (+1086.36%)
Mutual labels:  graphql, serverless
Api
Stars: ✭ 18 (-59.09%)
Mutual labels:  graphql, apollo-server
Firebase Gcp Examples
🔥 Firebase app architectures, languages, tools & some GCP things! React w Next.js, Svelte w Sapper, Cloud Functions, Cloud Run.
Stars: ✭ 470 (+968.18%)
Mutual labels:  graphql, serverless
Chatty
A WhatsApp clone with React Native and Apollo (Tutorial)
Stars: ✭ 481 (+993.18%)
Mutual labels:  graphql, apollo-server
Graphql Yoga
🧘 Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience
Stars: ✭ 6,573 (+14838.64%)
Mutual labels:  graphql, apollo-server
Firestore Apollo Graphql
An example of a GraphQL setup with a Firebase Firestore backend. Uses Apollo Engine/Server 2.0 and deployed to Google App Engine.
Stars: ✭ 371 (+743.18%)
Mutual labels:  graphql, apollo-server
Panther
Detect threats with log data and improve cloud security posture
Stars: ✭ 885 (+1911.36%)
Mutual labels:  graphql, serverless
Fullstack Tutorial
🚀 The Apollo platform tutorial app
Stars: ✭ 1,007 (+2188.64%)
Mutual labels:  graphql, apollo-server
Graphql Serverless
Sample project to guide the use of GraphQL and Serverless Architecture.
Stars: ✭ 28 (-36.36%)
Mutual labels:  graphql, serverless
React Firebase Starter
Boilerplate (seed) project for creating web apps with React.js, GraphQL.js and Relay
Stars: ✭ 4,366 (+9822.73%)
Mutual labels:  graphql, serverless
Apollo Resolvers
Expressive and composable resolvers for Apollostack's GraphQL server
Stars: ✭ 428 (+872.73%)
Mutual labels:  graphql, apollo-server
Webiny Js
Enterprise open-source serverless CMS. Includes a headless CMS, page builder, form builder and file manager. Easy to customize and expand. Deploys to AWS.
Stars: ✭ 4,869 (+10965.91%)
Mutual labels:  graphql, serverless
Apollo Errors
Machine-readable custom errors for Apollostack's GraphQL server
Stars: ✭ 405 (+820.45%)
Mutual labels:  graphql, apollo-server
Conference App In A Box
Full stack & cross platform app customizable & themeable for any event or conference.
Stars: ✭ 693 (+1475%)
Mutual labels:  graphql, serverless
Graphql Rust Demo
GraphQL Rust Demo
Stars: ✭ 37 (-15.91%)
Mutual labels:  graphql, apollo-server
Warthog
GraphQL API Framework with strong conventions and auto-generated schema
Stars: ✭ 316 (+618.18%)
Mutual labels:  graphql, apollo-server
Prisma1
💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB)
Stars: ✭ 16,851 (+38197.73%)
Mutual labels:  graphql, serverless
Create Social Network
An educational project, demonstrating how to build a large scalable project with Javascript.
Stars: ✭ 853 (+1838.64%)
Mutual labels:  graphql, apollo-server

Gatsby API

This is the GraphQL API that powers the maintainer dashboard for the Gatsby Store and the relevant parts of the docs like the feedback widget. It handles calls to privileged services such as Shopify and MailChimp to avoid exposing API keys in a client-side app.

Production environment

Services:

API:

Frameworks:

The way these services and frameworks work together is explained in more detail in the Architecture section below

API Reference

/graphql

All GraphQL calls for the store are sent to this endpoint.

For a full schema reference, see the schema.

/public

All GraphQL calls from gatsbyjs.org are sent to this endpoint.

For a full schema reference, see the schema.

Running This Repo Locally

Step 1: Clone the API

# Clone the repo.
git clone [email protected]:gatsbyjs/api.gatsbyjs.org.git

# Move into the newly cloned project.
cd api.gatsbyjs.org

# Install dependencies
yarn # or `npm install`

Step 2: Configure env variables

# Copy the example .env file into a real .env file
cp .env.EXAMPLE .env

The .env.EXAMPLE file contains a list of env variables used in various locations throughout the repository. Set each variable's value per your environment setup and credentials in .env.

Name Description
APP_LOGLEVEL The debug log output level.
APP_HOST The hostname of the API server.
APP_PORT The port number for the API server.
AUTH0_AUDIENCE The unique identifier for your Auth0 API.
AUTH0_DOMAIN Your Auth0 domain.
GITHUB_TEAM_ID The GitHub team to which the user should be added.
GITHUB_TOKEN Your GitHub authentication token.
GITHUB_ORG The GitHub organization to search for the user's contributions.
NODE_ENV The current Node environment in which the API server is running.
SHOPIFY_API_KEY Your Shopify API key.
SHOPIFY_API_SECRET Your Shopify API secret.
SHOPIFY_DISCOUNT_CODE The discount code supplied by the Shopify API for the user.
SHOPIFY_URI The Shopify API domain.

Step 3: Testing the API

The serverless-offline package only works to emulate AWS serverless code, since transitioning to GCP it's less ergonomic to test locally.

You can invoke a function locally with this command, (from to the serverless documentation):

serverless invoke local --function public --data '{ "query": "query { ping }" }'

However there are some issues circulating on the serverless-google-cloudfunctions package around better support for local emulation and development.

How to Test This API Using cURL

If you want to send straight-up POST requests so you can wear sunglasses indoors and pretend you’re a hacker, you can also send cURL requests like so:

curl \
  -H "Content-Type: application/json" \
  --data '{ "query": "query { getFeedback { id, comment } }" }' \
  -X POST http://localhost:3000/public
curl \
  -H "Content-Type: application/json" \
  --data '{
      "query": "query($user:String!) { contributorInformation(githubUsername:$user) { totalContributions } }",
      "variables": {
        "user": "[GITHUB_USERNAME]"
      }
    }' \
  -X POST http://localhost:3000/graphql

Note: These commands need the POST url to match a place where they are running like api.gatsbyjs.org, or to a local port if you're emulating the functions locally.

Deploying Changes

Before the functions can be deployed, you need to save a keys file to your local machine that the serverless.yml references.

Verify that you have downloaded the keys file from where it's stored (in 1Password for Gatsby employees) and referenced in the serverless.yml:

provider:
  name: google
  stage: dev
  runtime: nodejs10
  region: us-central1
  project: gatsby-core
  credentials: ~/Downloads/gatsby-core.json # <-- this needs to match where you're file is

The serverless deploy command is set up in the package.json to be run by the following yarn command:

yarn deploy

Serverless will zip up all the files and deploy them to Google Cloud Functions over the top of existing functions of the same name and project.

For deployment to multiple environments

Architecture

This repository is deployed using the Serverless framework to configure all the pieces of the infrastructure required to function. The following things take place on GCP:

  • the source code is packaged up uploaded to Google Cloud Storage
  • Functions are created for each GraphQL endpoint

Other pieces of the puzzle that fit everything together:

  • a DNS record pointing at the deployed functions needs to be set up for the domain that the API is being deployed to
  • a prisma service serves as the database for the feedback gathered by the feedback widget on gatsbyjs.org, the endpoint for it is in prisma/prisma.yml
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].