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
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: { |
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 MainLayout = ({ navigate }) => { | |
const session = useSession(); | |
return ( | |
<StyledMainLayout> | |
{!session.loading ? ( | |
<div> | |
<Navigation session={session} navigate={navigate} /> | |
<StyledContainer isLoggedIn={!!session.data}> | |
<Outlet context={session} /> |
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
"/" // -> Home view depends on session | |
"/about" // -> About show with session and without | |
"/login" // -> Login show with without session only | |
"/signup" // -> Sign Up show without session only | |
"/forgot-password" // -> Forgot Password show without session only | |
"/account" // -> User show with session only | |
"/settings" // -> Settings show with session only | |
"/posts" // -> Posts and nested routes show with session only | |
"*" // -> Not Found show without dependencies at all |