v3 (latest)
Integration with Gcp

Integration with Google Cloud Platform

Google Cloud Platform (GCP) is a suite of cloud computing services powered by Google. It is easy to use GraphQL Yoga with GCP.


yarn add graphql
yarn add graphql-yoga


import { createSchema, createYoga } from 'graphql-yoga'
// This is the endpoint of your GCP function
// Usually it is https://<region>-<project-id>.cloudfunctions.net/<function-name>
// We assume that your function name is `graphql`
const graphqlEndpoint = '/graphql'
const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        greetings: String
    resolvers: {
      Query: {
        greetings: () =>
          'This is the `greetings` field of the root `Query` type'
// The exported variable name should be the same with `Entry point` value defined in Cloud Functions configuration
export function graphql(req, res) {
  // GCP doesn't expose the full path so we need to patch it
  req.url = graphqlEndpoint + req.url
  return yoga(req, res)

This example uses ESM syntax, so you set "type": "module" in your package.json.

You can also check a full example on our GitHub repository here (opens in a new tab)