This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "boilerplate-graphql-koa-server-external", | |
"version": "1.0.0", | |
"description": "Boilerplate GraphQL Koa server external", | |
"main": "src/index.js", | |
"scripts": { | |
"start": "PORT=4000 node src/index.js" | |
}, | |
"engines": { | |
"node": "16.17.x" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Koa = require('koa'); | |
const http = require('http'); | |
const cors = require('@koa/cors'); | |
const { ApolloServer } = require('apollo-server-koa'); | |
const { makeExecutableSchema } = require('@graphql-tools/schema'); | |
const typeDefs = require('./schema'); | |
const resolvers = require('./resolvers'); | |
async function server({ typeDefs, resolvers }) { | |
const app = new Koa(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { gql } = require('apollo-server-koa'); | |
module.exports = gql` | |
type Query { | |
getItemsExternal: [DataExternalExample] | |
} | |
type DataExternalExample { | |
id: ID | |
label: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fakeData = { | |
id: 223421, | |
label: 'Some Label From External', | |
}; | |
module.exports = { | |
Query: { | |
getItemsExternal: () => [fakeData], | |
}, | |
Mutation: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "boilerplate-graphql-koa-server", | |
"description": "Boilerplate GraphQL Koa server", | |
"scripts": { | |
"start": "PORT=3000 node src/index.js" | |
}, | |
"dependencies": { | |
"@graphql-tools/load": "^7.7.5", | |
"@graphql-tools/url-loader": "^7.14.1", | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the same imports as it was in boilerplate-graphql-koa-server-external | |
const { loadSchema } = require('@graphql-tools/load'); | |
const { UrlLoader } = require('@graphql-tools/url-loader'); | |
const { makeExecutableSchema, mergeSchemas } = require('@graphql-tools/schema'); | |
const EXTERNAL_ENDPOINT = 'http://localhost:4000/api/v1/graphql'; | |
async function server({ typeDefs, resolvers }) { | |
// app and httpServer the same like in boilerplate-graphql-koa-server-external |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Koa = require('koa'); | |
const http = require('http'); | |
const cors = require('@koa/cors'); | |
const { ApolloServer } = require('apollo-server-koa'); | |
const { loadSchema } = require('@graphql-tools/load'); | |
const { UrlLoader } = require('@graphql-tools/url-loader'); | |
const { makeExecutableSchema, mergeSchemas } = require('@graphql-tools/schema'); | |
const typeDefs = require('./schema'); | |
const resolvers = require('./resolvers'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { gql } = require('apollo-server-koa'); | |
module.exports = gql` | |
type Query { | |
getFakeDataExample: DataExample | |
} | |
type DataExample { | |
id: ID | |
value: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fakeData = { | |
id: 4838745, | |
value: 'Some Random String', | |
}; | |
module.exports = { | |
Query: { | |
getFakeDataExample: () => fakeData, | |
}, | |
Mutation: { |
OlderNewer