Skip to content

Commit

Permalink
Rfc/issue 115 build time data access (#269)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thescientist13 committed Mar 15, 2020
1 parent ad9515b commit 123333a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/cli/src/data/queries/hello.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query {
hello
}
18 changes: 18 additions & 0 deletions packages/cli/src/data/schema/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { gql } = require('apollo-server');

const helloTypeDefs = gql`
type HelloQuery {
hello: String
}
`;

const helloResolvers = {
HelloQuery: {
hello: () => 'Hello world!'
}
};

module.exports = {
helloTypeDefs,
helloResolvers
};
1 change: 1 addition & 0 deletions www/components/shelf/shelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Shelf extends LitElement {
parent: page
}
});

console.log('response from the shelf (data.children)', response.data.children);

this.shelfList = list;
Expand Down
3 changes: 1 addition & 2 deletions www/pages/docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Greenwood exposes a [GraphQL](https://graphql.org/) + [Apollo](https://www.apoll
![graphql-playground](/assets/graphql-playground.png)

#### Schema
To kick things off, let's review what is availalble to you. Currently, the main "API" is just a list of all pages in your _pages/_ directory, represented as a `Page` [type definition](https://graphql.org/graphql-js/basic-types/). This is called Greenwood's `graph`.

To kick things off, let's review what is available to you. Currently, the main "API" is just a list of all pages in your _pages/_ directory, represented as a `Page` [type definition](https://graphql.org/graphql-js/basic-types/). This is called Greenwood's `graph`.

This is what the schema looks like:
```render javascript
Expand Down

0 comments on commit 123333a

Please sign in to comment.