-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rfc/issue 115 build time data access #269
Rfc/issue 115 build time data access #269
Conversation
package.json
Outdated
@@ -20,8 +20,8 @@ | |||
"build": "yarn clean && node . build", | |||
"serve": "yarn build && cd ./public && ws", | |||
"develop": "yarn clean && node . develop", | |||
"test": "yarn clean && nyc mocha ./packages/**/test/**/**/*.spec.js --timeout 30000", | |||
"test:tdd": "yarn clean && mocha --watch ./packages/**/test/**/**/*.spec.js --timeout 15000" | |||
"test": "export BROWSERSLIST_IGNORE_OLD_DATA=true && yarn clean && nyc mocha ./packages/**/test/**/**/*.spec.js --timeout 30000", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to do this to keep the browserslist message from interfering in our tests that were testing for stderr
browserslist/browserslist#361
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that in development mode as well.
Browserslist: caniuse-lite is outdated. Please run next command
yarn upgrade``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got a good amount of test cases in now for data serialization, however, and I think this may more have to do with usage of JSON.stringify
/ JSON.parse
not maintaining consistent ordering or keys (even when trying to use deep.equalInAnyOrder
in the tests), but it further highlights the need why something like #271 needs to be implemented as part of any release that includes this RFC.
Essentially, if you look at the test for Blog Posts, because things aren't deterministic, the order of blog pages (/blog/first-post/ and /blog/second-post/) can come back in inconsistent order which is why I can't test the full title / link contents, and had to fallback to using .contain
as opposed to .equal
. In fact, while equalInAnyOrder
makes testing easier, think of a user getting a different order of results potentially each time. Probably gonna have a bad time. ⛷
So not only should be users be able to specify an order if they want, but at the very least our default return order should always be consistent. I will include a comment to this effect in #271 and escalate its priority.
At least it's enough to finish the last few TODOs on my list though, which I will be able to clean up tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hutchgrant / @aholtzman
OK! I think this is ready to go now, please let me know if you have any feedback. I will plan on using this as the start of a release/0.5.0 branch with the set of issues to be included per our last meeting.
Phew, really excited to land this one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to see these changes coming and especially glad to see large improvements made on my initial idea to something much more stable, practical and polished. The rehydration issue with the client and the render issue of the cache on the server being fixed made me excited. I watched every improvement to this PR and am glad we're moving this forward to 0.5.0
On initial cursory review, I found that the sorting issue being fixed is a necessity for successful testing and in practise. Perhaps that can be added post-merge. As well I found tiny things you missed in your continued improvements(typo here, outdated info there)
I would like the cache reading/writing loop to be done asynchronously pre-merge with 0.5.0 release branch as I feel it shouldn't require that many changes and is necessary.
I'd like to go over the documentation first, along with these tiny changes, before I give full approval, but you already know how I feel about this 🎉
edit: your apollo wrapper(inspired by lit-apollo no doubt) solution, to handle the conditional rendering/fetching of the cache, is good, simple, logic 🥇
const pages = await glob.promise(path.join(publicDir, '**/**/index.html')); | ||
|
||
pages.forEach((pagePath) => { | ||
const contents = fs.readFileSync(pagePath, 'utf-8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned this section needs to be asynchronous. Reading a file, merging a file, writing to file, and repeating that through however many pages. That's going to cause problems if not done asynchronously. For an RFC it's fine, but before release, that needs to be fixed. #277
www/pages/docs/data.md
Outdated
`import` the query in your component | ||
```render javascript | ||
import client from '@greenwood/cli/data/client'; | ||
import ChildrenQuery from '@greenwood/cli/data/queries/cnildren'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'@greenwood/cli/data/queries/cnildren';
typo: /children
@@ -25,6 +28,25 @@ class shelf extends LitElement { | |||
this.expandRoute(window.location.pathname); | |||
} | |||
|
|||
async setupShelf(page) { | |||
console.log('setupShelf for page =>', page); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize console.log is for debug of shelf and can be removed later I suppose with #275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we'll definitely want to catch. I did notice that in prod mode (at least) the shelf seems to load twice, even from the graph. I understand that it would load once for no route, then when the route is set, but it seems to do that twice? Something I'm keeping my eye on and will show on our next call. 👀
www/pages/about/community.md
Outdated
@@ -6,6 +6,7 @@ Greenwood understands the role of community in open source, technology, and lear | |||
- [**puppeteer**](https://github.com/GoogleChrome/puppeteer) - Headless Chrome browser used for serializtion. | |||
- [**WC Markdown Loader**](https://github.com/hutchgrant/wc-markdown-loader/) - A webpack plugin that transforms a markdown file into a Web Component! 🤯 | |||
- [**LitReduxRouter**](https://github.com/fernandopasik/lit-redux-router) - Declarative client side routing library. | |||
- [**LitApollo**](https://www.npmjs.com/package/@apollo-elements/lit-apollo) - Base component class for connecting to Greenwood's build time GraphQL server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer using lit-apollo
edit: but understandable if you wish to highlight the project because it inspired the apollo client wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yeah. I ended up taking it out. If anything, the idea of the client wrapper is probably more inspired by the Proxy Pattern from the Gang of Four's design patterns.
www/pages/docs/data.md
Outdated
``` | ||
|
||
### Internal Sources | ||
Greenwood exposes a [GraphQL](https://graphql.org/) + [Apollo](https://www.apollographql.com/docs/apollo-server/) server locally when developing available at `localhost:4000` that can be used to get information about your local content like path, "slug", title and other useful information that will be dynamic to the content you have. Programmatic access to this data can provide the oppourtunirty to share your content with your users in a way that supports sorting, filter, organizing, and more! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oppourtunirty
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phew... where's my spell checker plugin at? 🙈 🤣
www/pages/docs/data.md
Outdated
#### Schema | ||
To kick things off, let's review what is availalble to you from. Currently, the main "API" is just a list of all pages in your _pages/_ directory, represented as a `Page` [type defintion](https://graphql.org/graphql-js/basic-types/). This is called Greenwood's `graph`. | ||
|
||
This is that the schema looks like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is that the schema looks like:
This is what
the schema looks like
www/pages/docs/data.md
Outdated
|
||
Below are the queries available: | ||
|
||
#### Graph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graph is a subheading of queries, but it shares the same font-size due to both being h4. What do you think about the organization here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I can just add one extra #
to each heading then. But maybe better to consider @data
as it's own package, as since it will be such a key feature, it might make sense to make it its own navigation item, which would give these docs more opportunity to breath, as it were.
47073c6
to
72560ee
Compare
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * unit test data graph * linting * lint fix * added ordered index tracking when serializing pages * formatting * document graph page ordering * cli data graph unit tests and expand mocha spec globbing * address missing hash in mock graph * loosen graph test case asserts * update graph tests to focus less on implementation details * add back missing develop task
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * unit test data graph * linting * lint fix * added ordered index tracking when serializing pages * formatting * document graph page ordering * cli data graph unit tests and expand mocha spec globbing * address missing hash in mock graph * loosen graph test case asserts * update graph tests to focus less on implementation details * add back missing develop task
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * unit test data graph * linting * lint fix * added ordered index tracking when serializing pages * formatting * document graph page ordering * cli data graph unit tests and expand mocha spec globbing * address missing hash in mock graph * loosen graph test case asserts * update graph tests to focus less on implementation details * add back missing develop task
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * hello and graph queries working together * config def and resolvers * use real config data * flesh out config schema and query * remove theme file from config * delete hello query example * config unit tests * rename mock graph * formatting * documentation
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * fix cache.json lookup for deep linking * clean up from rebase * clean up from rebase
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * hello and graph queries working together * config def and resolvers * flesh out config schema and query * remove theme file from config * delete hello query example * formatting * documentation * app template with config title from data * page title with project title * tests for custom page title * cleanup console log * docs
* graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * hello and graph queries working together * config def and resolvers * flesh out config schema and query * remove theme file from config * delete hello query example * formatting * documentation * app template with config title from data * tests for custom page title * refactoring meta to app-template and data instead of scaffolding and added tests * update coverage config * fix spelling mistake
* Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * Bug/issue 271 determinism (#292) * Rfc/issue 115 build time data access (#269) * graphql server working * apollo client connect to apollo server * connected header example using lit apollo * todo * todos * query and client + server refactor * schema refactoring * clean up console logging * alias all @greenwood/cli/data module imports * avoid paramater destructuring * graphql example in the header * multiple schemas * internal data sources documentation * shelf refactor and children query integration * refactor out ApolloQuery * ability to intercept client.query calls * basic semi-working implementation * remove extra config from server context * have puppeteer wait for graphql requests before returning content * fix and add test cases for apollo * merged resolvers not actually working * multiple queries support * everything working * todos * TODO tracking * fix fallback apollo client fetch handling * full test suite * cache json test cases * stablize test due to inconsistent data results ordering * clean up deps * todo cleanup * remove forced client call in SSG mode for client * represent graph through the schema * updated data docs * typos and grammer * typos and community link fixes * unit test data graph * linting * lint fix * added ordered index tracking when serializing pages * formatting * document graph page ordering * cli data graph unit tests and expand mocha spec globbing * address missing hash in mock graph * loosen graph test case asserts * update graph tests to focus less on implementation details * add back missing develop task * task: refactor into single menu query, enable menu filtering with markdown declarations * fix shelf * fix: shelf rendering collapse/expand * test: update al related tests * fix: remove debug * task: basic sorting label/index * fix: index sorting * fix: remove debug * fix: current tests * test: amending tests, removing prev mock * test: revert previous graphql test case * test: remove hello query * fix: remove deprecated .json files * fix: refactor mock graph func * test: adding sort/filter menu tests * task: add documentation for menus * fix: amend documentation * fix: amend docs for route var * fix: typo * task: add headingLevel and route condition, remove hardcoded vars * fix: non-pathname menus may want linkheadings children * task: amend docs for child heading level * fix: change linkheadings to integer, use for headingLevel * docs: remove navigation query docs * test: fix test * task: revert stub generation code * fix: update data sources doc * fix: amend docs for route/linkheadings additions * fix: update filter to use title instead of label * fix: test * task: update docs with linkheadings query result Co-authored-by: Owen Buckley <[email protected]>
Related Issue
resolves #115
Summary of Changes
takes deep breath...
First of all, BIG shout out to @hutchgrant for the getting this going in #251, of which this PR was based off of. Will try and highlight all the relevant additions / modifications here, but there is a lot to go through so will do my best. Still a couple more
TODO
items and questions to go over, but this is it. We did it. 🏆@greenwood/cli/data
Created this "alias" package to expose server, client, and cache.js files for the CLI and for consumers.
Main thing of note is that we wrap ApolloClient and determine where the data should come from.
Server Side Rendering
One difference is now the data is being rendered server side. As the calls come into the GraphQL server, they will be written to uniquely-hashed named JSON files, and then during the serialize phase are written to index.html in
window.___APOLLO_STATE
. This implements a more traditional server side rendering technique and integrated it with the headerFor example, while the code for the header is
In the serialized HTML, we now see this! (which wasn't happening when it was being client side rendered)
The client the user consumes will be able to intelligently tell if the calls should be live (development mode, or read from cache / disk instead of over the wire)
GraphQL
To start things off, I have defined the CLI's graph as a type in GraphQL. I am using this to render the header and confirming that the Shelf would correctly get the data, but there is the issue of sorting though...
We are lucky that the navigation order in our header is already alpha-sorted. I think we will need to improve how we can query the graph in a more "declarative" way and / or customizable from a user perspective (e.g. providing a custom sort order). Will discuss more in the Follow Ups section.
I left console logging in for now to help with seeing this all working. Will remove before the PR is merged.
TODOs
console.log
from the shelf not display response data (though cache.json file is loading fine)fetch().catch()
Page
typeDef defintion based on internal graph objectstate.getAttribute('data-state')
release/0.5.0
branch and PR, tracking relevant issuesFollow Ups
0.5.0
release). This will also need to figure out a way to merge resolvers / typeDefs in schema.js. - Made expose Greenwood configuration as data #2700.5.0
release) - query results are not deterministic #271That the graphql server writes to the cache - which has to make a call back to the graphql server just to extract the data... that's definitely an opportunity to optimizeimprove cache.json generation implementation (reduce duplicated grapqhl calls in serialization workflow) #272In resolvers, assuming a certain amount of depth to the pages, e.g.- resolvers and file writing assumes certain route depth #273split('/')[0]
generating JSON in cache, globbing in serialize, assuming filename cache.json- improve performance and generation of cache.json file #277require
calls from the shelf - add support for dynamic imports #275Browserslist: caniuse-lite is outdated. Please run next command yarn upgrade
- update browserslist version #276@greenwood/cli/data
as its own package? - GraphQL (Apollo) data as its own package #278