Skip to content

Instantly share code, notes, and snippets.

View antonkalik's full-sized avatar
💻
coding...

Anton Kalik antonkalik

💻
coding...
View GitHub Profile
{
"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"
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();
const { gql } = require('apollo-server-koa');
module.exports = gql`
type Query {
getItemsExternal: [DataExternalExample]
}
type DataExternalExample {
id: ID
label: String
}
const fakeData = {
id: 223421,
label: 'Some Label From External',
};
module.exports = {
Query: {
getItemsExternal: () => [fakeData],
},
Mutation: {
{
"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",
}
const { gql } = require('apollo-server-koa');
module.exports = gql`
type Query {
getFakeDataExample: DataExample
}
type DataExample {
id: ID
value: String
}
const fakeData = {
id: 4838745,
value: 'Some Random String',
};
module.exports = {
Query: {
getFakeDataExample: () => fakeData,
},
Mutation: {
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');
@antonkalik
antonkalik / MainLayout.js
Last active September 4, 2022 17:37
The wrapper for routes
const MainLayout = ({ navigate }) => {
const session = useSession();
return (
<StyledMainLayout>
{!session.loading ? (
<div>
<Navigation session={session} navigate={navigate} />
<StyledContainer isLoggedIn={!!session.data}>
<Outlet context={session} />
"/" // -> 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