-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: implementing basic graphql injection example
- Loading branch information
1 parent
e62710f
commit 560f303
Showing
32 changed files
with
980 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const WebpackDevServer = require('webpack-dev-server'); | ||
const runGraphQLServer = require('../../../plugin-graphql/src/server.js'); | ||
|
||
module.exports = runDevServer = async (compilation) => { | ||
return new Promise(async (resolve, reject) => { | ||
|
||
try { | ||
runGraphQLServer(compilation.graph); | ||
const webpackConfig = require(path.join(__dirname, '..', './config/webpack.config.develop.js'))(compilation); | ||
const devServerConfig = webpackConfig.devServer; | ||
|
||
let compiler = webpack(webpackConfig); | ||
let webpackServer = new WebpackDevServer(compiler, devServerConfig); | ||
|
||
webpackServer.listen(devServerConfig.port); | ||
|
||
} catch (err) { | ||
reject(err); | ||
} | ||
|
||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@greenwood/plugin-graphql", | ||
"version": "0.4.0", | ||
"description": "A plugin for Greenwood to enable use of GraphQL", | ||
"repository": "https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-graphql", | ||
"author": "Grant Hutchinson <[email protected]>", | ||
"license": "MIT", | ||
"keywords": [ | ||
"Greenwood", | ||
"Web Components", | ||
"Lit Element", | ||
"Lit Html", | ||
"Static Site Generator", | ||
"GraphQL" | ||
], | ||
"main": "src/index.js", | ||
"files": [ | ||
"src/" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"@greenwood/cli": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"@greenwood/cli": "^0.4.0" | ||
}, | ||
"dependencies": { | ||
"apollo-server": "^2.9.7", | ||
"graphql": "^14.5.8", | ||
"lodash": "^4.17.15" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
/* Queries */ | ||
exports.getMenu = async (root, { name }, { graph }) => { | ||
|
||
const items = graph | ||
.filter((page) => page.menu === name) | ||
.map(({ title, route }) => { | ||
return { path: route, name: title, items: [] }; | ||
}); | ||
|
||
return { name, items }; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { gql } = require('apollo-server-express'); | ||
const { merge } = require('lodash'); | ||
|
||
const { menuTypeDefs, menuResolvers } = require('./schemas/menu-schema'); | ||
|
||
exports.typeDefs = gql` | ||
${menuTypeDefs} | ||
`; | ||
|
||
exports.resolvers = merge( | ||
menuResolvers, | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { gql } = require('apollo-server-express'); | ||
const { | ||
getMenu | ||
} = require('../lib/menu-queries'); | ||
|
||
exports.menuTypeDefs = gql` | ||
type Menu { | ||
name: String! | ||
path: String! | ||
items: [MenuItem] | ||
} | ||
type MenuItem { | ||
name: String! | ||
path: String! | ||
items: [SubMenuItem] | ||
} | ||
type SubMenuItem { | ||
name: String! | ||
id: String! | ||
} | ||
type Query { | ||
getMenu(name: String!): Menu | ||
} | ||
`; | ||
|
||
exports.menuResolvers = { | ||
Query: { | ||
getMenu | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// GraphQL-Express middleware | ||
const { ApolloServer } = require('apollo-server'); | ||
const { typeDefs, resolvers } = require('./schema'); | ||
|
||
module.exports = (graph) => { | ||
|
||
// Create schema | ||
// disable playground in prod | ||
const server = new ApolloServer({ | ||
typeDefs, | ||
resolvers, | ||
playground: { | ||
endpoint: '/graphql', | ||
settings: { | ||
'request.credentials': 'include', | ||
'editor.theme': 'light' | ||
} | ||
}, | ||
context: () => ({ | ||
graph | ||
}) | ||
}); | ||
|
||
// The `listen` method launches a web server. | ||
server.listen().then(({ url }) => { | ||
console.log(`🚀 Server ready at ${url}`); | ||
}); | ||
|
||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
--- | ||
menu: about | ||
title: Features | ||
--- | ||
|
||
## Features | ||
|
||
#### Onboarding | ||
We built Greenwood in the hopes that getting started would be easy. By default Greenwood will build an app for you. Just simply start adding pages and customizing templates as needed and you're good to go! You pick your workspace, Greenwood makes as few assumptions as needed to deliver an optimal development experience with minimum configuration needed. | ||
|
||
We strive to provide good documentation, intuitive developer experiences, and stable workflows. Even if you don't know anything about webpack or Web Components, if you can learn a little markdown, you can get started making a modern website right away! | ||
We strive to provide good documentation, intuitive developer experiences, and stable workflows. Even if you don't know anything about webpack or Web Components, if you can learn a little markdown, you can get started making a modern website right away! | ||
|
||
|
||
#### Modern Apps, Modern Toolchains | ||
At the heart of Greenwood is an "evergreen" build, that aims to deliver the most optimized user experience through a combination of tools like webpack, babel, and PostCSS. | ||
At the heart of Greenwood is an "evergreen" build, that aims to deliver the most optimized user experience through a combination of tools like webpack, babel, and PostCSS. | ||
|
||
Develop like it's a Single Page Application, deploy like it's a static site. (because it is!) | ||
|
||
|
||
#### Performance | ||
We believe delivering a great user experience is above all else the most crucial element to a successful web product and part of that means performance out of the box. Greenwood wants to help your site be one of the fastest out there and so we'll take care of all those optimizations for you, ensuring your site gets a great score in tools like [Lighthouse](https://developers.google.com/web/tools/lighthouse/), one of our primary performance benchmarking tools. | ||
We believe delivering a great user experience is above all else the most crucial element to a successful web product and part of that means performance out of the box. Greenwood wants to help your site be one of the fastest out there and so we'll take care of all those optimizations for you, ensuring your site gets a great score in tools like [Lighthouse](https://developers.google.com/web/tools/lighthouse/), one of our primary performance benchmarking tools. | ||
|
||
|
||
Haven't given Greenwood a try yet? Check out our [Getting Started](/getting-started) guide and start building your next modern web experience! 💯 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
--- | ||
menu: about | ||
title: Goals | ||
--- | ||
|
||
## Goals | ||
|
||
#### It's Not About Us | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.