Skip to content

Instantly share code, notes, and snippets.

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@erebus1
erebus1 / setup.sh
Created November 6, 2018 16:29
Set up test repo
mkdir test
cd test
git init
mkdir a
touch a/a.txt
touch b.txt
printf "hello\ne" >> a/a.txt
printf "test\ntrololo" >> b.txt
git add ./
git commit -m "init" -a
@erebus1
erebus1 / stitcher.js
Last active November 8, 2019 13:29
GQL Schema Stitcher
const monolith_url: string = process.env.APOLLO_URL
const file_manager_url: string = process.env.FILE_MANAGER_URL
async function run() {
// logic on how extract files from file microservice
function getBatchFiles(context) {
return function batchFiles(keys: string[]): Promise<Array<{} | null>> {
return new Promise(function (resolve, reject) {
const query = `
from graphene import Schema, ObjectType, Int, String, List, NonNull
from utils import file_loader # custom data loader
class FileNode(ObjectType):
id = Int(required=True)
url = String(required=True)
from graphene import ObjectType, Int, List, String, Field, NonNull
from graphene_federation import build_schema, extend, external
@extend(fields='id')
class FileNode(ObjectType):
id = external(Int(required=True))
class MessageNode(ObjectType):
import graphene
from graphene import ObjectType, Int, String
from graphene_federation import build_schema, key
from utils import file_loader # custom data loader
@key(fields='id')
class FileNode(ObjectType):
id = Int(required=True)
import {ApolloServer} from 'apollo-server'
import {ApolloGateway} from '@apollo/gateway'
const monolith_url: string = 'http://monolith:5000/graphql';
const filemanager_url: string = 'http://filemanager:5000/graphql';
const gateway = new ApolloGateway({
serviceList: [
{ name: 'monolith', url: monolith_url },
{ name: 'filemanager', url: filemanager_url },
],
const monolith_url: string = process.env.APOLLO_URL
const file_manager_url: string = process.env.FILE_MANAGER_URL
async function run() {
// logic on how extract files from file microservice
function getBatchFiles(context) {
return function batchFiles(keys: string[]): Promise<Array<{} | null>> {
return new Promise(function (resolve, reject) {
// query file microservice here
const monolith_url: string = process.env.APOLLO_URL
const file_manager_url: string = process.env.FILE_MANAGER_URL
async function run() {
// logic on how extract files from file microservice
function getBatchFiles(context) {
return function batchFiles(keys: string[]): Promise<Array<{} | null>> {
return new Promise(function (resolve, reject) {
// query file microservice here
type MessageNode {
id: Int!
body: String!
files: [FileNode!]
}
type FileNode {
id: Int!
}