Commit 0977e751 authored by Jens's avatar Jens
Browse files

drop editor

parent 2775d37f
webpackJsonp([0],{240:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(0),a=l(24);t.default=class extends r.Component{render(){return n.createElement("div",null,n.createElement("h1",null,"Header"),n.createElement("ul",null,n.createElement("li",null,n.createElement(a.Link,{to:"/"},"Main")),n.createElement("li",null,n.createElement(a.Link,{to:"/authors"},"Authors")),n.createElement("li",null,n.createElement(a.Link,{to:"/articles"},"Articles"))))}}},241:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(0);t.default=class extends r.Component{render(){return n.createElement("div",null,n.createElement("p",null,"Main"))}}},242:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(0),a=l(77),o=l(31),u=a.default`
query getAllAuthors {
allAuthors {
totalCount
nodes {
nodeId
id
name
bornIn
articlesByAuthorId {
totalCount
}
}
}
}
`;t.default=class extends r.Component{render(){return n.createElement("div",null,n.createElement("p",null,"Authors"),n.createElement(o.Query,{query:u},e=>e.loading?n.createElement("p",null,"Loading..."):e.error?n.createElement("p",null,e.error.message):n.createElement("ol",null,e.data.allAuthors.nodes.map(e=>n.createElement("li",null,n.createElement("h3",null,e.name),n.createElement("h4",null,e.bornIn),n.createElement("p",null,"Total Articles Count: ",e.articlesByAuthorId.totalCount))))))}}},252:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(0),a=l(77),o=l(31),u=a.default`
query getAllArticles {
allArticles {
totalCount
nodes {
nodeId
id
title
description
content
authorId
authorByAuthorId {
id
}
}
}
}
`;t.default=class extends r.Component{render(){return n.createElement("div",null,n.createElement(o.Query,{query:u},e=>e.loading?n.createElement("div",null,"Loading..."):e.error?n.createElement("div",null,"Error: ",e.error.message):n.createElement("div",null,n.createElement("p",null,"Articles"),n.createElement("ol",null,e.data.allArticles.nodes.map(e=>n.createElement("li",{key:e.nodeId},n.createElement("h3",null,e.title),e.description&&n.createElement("p",null,e.description)||n.createElement("p",null,"No description available")))))))}}},45:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(0),a=l(24),o=l(240),u=l(241),c=l(242),d=l(252);t.default=class extends r.Component{render(){return n.createElement("div",null,n.createElement(o.default,null),n.createElement(a.Route,{exact:!0,path:"/",component:u.default}),n.createElement(a.Route,{exact:!0,path:"/authors",component:c.default}),n.createElement(a.Route,{exact:!0,path:"/articles",component:d.default}))}}},82:function(e,t,l){l(83),e.exports=l(92)},92:function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=l(0),r=l(94),a=l(24),o=l(31),u=l(200),c=l(218),d=l(231),s=new c.default({link:new u.default({uri:"/graphql"}),cache:(new d.InMemoryCache).restore(window.__APOLLO_STATE__)}),i=l(45),m=document.getElementById("react-root"),E=e=>n.createElement(o.ApolloProvider,{client:s},n.createElement(a.BrowserRouter,null,n.createElement(e,null)));e.hot.accept(45,()=>{Promise.resolve().then(()=>l(45)).then(e=>{r.hydrate(E(e.default),m)})}),r.hydrate(E(i.default),m)}},[82]);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/* tslint:disable */
// This file was automatically generated and should not be edited.
export interface getAllArticlesQuery {
// Reads and enables pagination through a set of `Article`.
allArticles: {
__typename: "ArticlesConnection",
// The count of *all* `Article` you could get from the connection.
totalCount: number | null,
// A list of `Article` objects.
nodes: Array< {
__typename: "Article",
// A globally unique identifier. Can be used in various places throughout the system to identify this single value.
nodeId: string,
id: string,
title: string | null,
description: string | null,
content: string | null,
authorId: string,
// Reads a single `Author` that is related to this `Article`.
authorByAuthorId: {
__typename: "Author",
id: string,
name: string,
} | null,
} | null >,
} | null,
};
export interface getAllAuthorsQuery {
// Reads and enables pagination through a set of `Author`.
allAuthors: {
__typename: "AuthorsConnection",
// The count of *all* `Author` you could get from the connection.
totalCount: number | null,
// A list of `Author` objects.
nodes: Array< {
__typename: "Author",
// A globally unique identifier. Can be used in various places throughout the system to identify this single value.
nodeId: string,
id: string,
name: string,
// Reads and enables pagination through a set of `Article`.
articlesByAuthorId: {
__typename: "ArticlesConnection",
// The count of *all* `Article` you could get from the connection.
totalCount: number | null,
},
} | null >,
} | null,
};
This diff is collapsed.
{
"name": "renderine",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-server": "webpack --config webpack.server.config.js --progress",
"build-client": "webpack --config webpack.client.config.js --progress",
"start": "node ./dist/server/server.js",
"introspect-graphql-schema": "./node_modules/.bin/apollo-codegen introspect-schema http://localhost:8081/graphql --output schema.json",
"generate-graphql-ts": "./node_modules/.bin/apollo-codegen generate **/*.tsx --addTypename --schema schema.json --target typescript --output graphql-types.ts"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/graphql": "^0.12.3",
"@types/react": "^16.0.35",
"@types/react-router-dom": "^4.2.3",
"apollo-cache-inmemory": "^1.1.5",
"apollo-client": "^2.2.1",
"apollo-link-http": "^0.6.1-beta.6",
"express": "^4.16.2",
"graphql": "^0.12.3",
"graphql-tag": "^2.6.1",
"node-fetch": "^2.0.0-alpha.9",
"postgraphile": "^4.0.0-alpha2.30",
"react": "^16.2.0",
"react-apollo": "^2.0.4",
"react-async-bootstrapper": "^1.1.2",
"react-async-component": "^1.0.2",
"react-dom": "^16.2.0",
"react-render-image": "^1.1.1",
"react-router-dom": "^4.2.2",
"typescript": "^2.6.2",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"@types/express": "^4.11.0",
"@types/node": "^9.4.0",
"@types/node-fetch": "^1.6.7",
"@types/react-dom": "^16.0.3",
"@types/systemjs": "^0.20.6",
"@types/webpack-env": "^1.13.4",
"apollo-codegen": "^0.18.3",
"awesome-typescript-loader": "^3.4.1",
"extract-text-webpack-plugin": "^3.0.2",
"react-hot-loader": "^3.1.3",
"source-map-loader": "^0.2.3",
"uglifyjs-webpack-plugin": "^1.1.8",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.2",
"webpack-dev-middleware": "^2.0.4",
"webpack-hot-middleware": "^2.21.0",
"webpack-stats-plugin": "^0.1.5"
}
}
This diff is collapsed.
import * as React from 'react'
import { Component } from 'react'
import { hydrate } from 'react-dom'
import { BrowserRouter as Router } from 'react-router-dom'
import { ApolloProvider } from 'react-apollo';
import HttpLink from "apollo-link-http";
import ApolloClient from "apollo-client";
import { InMemoryCache } from "apollo-cache-inmemory";
import { AsyncComponentProvider, createAsyncContext } from 'react-async-component'
import asyncBootstrapper from 'react-async-bootstrapper'
import Routes from '../common/routes'
declare let window: {
__APOLLO_STATE__: any,
__ASYNC_STATE__: any
}
declare let module: {
hot: {
accept: (path: any, fn: () => any) => any
}
}
const apolloClient = new ApolloClient({
link: new HttpLink({ uri: "/graphql" }),
cache: new InMemoryCache().restore(window.__APOLLO_STATE__)
});
const reactRoot: HTMLElement = document.getElementById('react-root');
const render = (Routings: React.ComponentClass) => {
return (
<AsyncComponentProvider rehydrateState={window.__ASYNC_STATE__} >
<ApolloProvider client={apolloClient}>
<Router>
<Routings />
</Router>
</ApolloProvider>
</AsyncComponentProvider>
)
}
if (module.hot) {
module.hot.accept('../common/routes', () => {
import('../common/routes').then((module: any) => {
hydrate(render(module.default), reactRoot)
})
})
}
const App = render(Routes);
asyncBootstrapper(App)
.then(() => hydrate(App, reactRoot));
//delete window.__APOLLO_STATE__;
//delete window.__ASYNC_STATE__;
\ No newline at end of file
import * as React from 'react'
import {Component} from 'react'
import gql from 'graphql-tag';
import {getAllArticlesQuery} from '../../../graphql-types'
import { graphql, QueryProps } from 'react-apollo';
const query = gql`
query getAllArticles {
allArticles {
totalCount
nodes {
nodeId
id
title
description
content
authorId
authorByAuthorId {
id
name
}
}
}
}
`
interface Props {
data: QueryProps & getAllArticlesQuery
}
class AllArticles extends Component<Props> {
render() {
if (this.props.data.loading){
return <div>Loading...</div>
} else if (this.props.data.error){
return <div>Error: {this.props.data.error.message}</div>
}
return (
<ul>
{
this.props.data.allArticles.nodes.map(article => (
<div key={article.nodeId}>
<h4>{article.title}</h4>
<p>{article.description}</p>
<div>Written by: {article.authorByAuthorId.name}</div>
</div>
))
}
</ul>
);
}
}
export default graphql<getAllArticlesQuery,Props,{}>(query)(AllArticles);
\ No newline at end of file
import * as React from 'react'
import gql from 'graphql-tag';
import {graphql,QueryProps} from 'react-apollo'
import {getAllAuthorsQuery} from '../../../graphql-types';
const query = gql`
query getAllAuthors {
allAuthors {
totalCount
nodes {
nodeId
id
name
articlesByAuthorId {
totalCount
}
}
}
}
`;
interface Props {
data: QueryProps & getAllAuthorsQuery
}
class AllAuthors extends React.Component<Props> {
render() {
if (this.props.data.loading){
return <div>Loading...</div>
} else if (this.props.data.error){
return <div>Error: {this.props.data.error.message}</div>
}
return (
<div>
<h2>Authors</h2>
<ul>
{
this.props.data.allAuthors.nodes.map(author => (
<li key={author.nodeId}>
<div>Name: {author.name}</div>
<div>NumberOfArticles: {author.articlesByAuthorId.totalCount}</div>
</li>
))
}
</ul>
</div>
)
}
}
export default graphql<getAllAuthorsQuery,Props,{}>(query)(AllAuthors);
\ No newline at end of file
import * as React from 'react';
import { asyncComponent } from 'react-async-component';
export default asyncComponent({
resolve: () => System.import('./allAuthors.tsx')
});
\ No newline at end of file
import * as React from 'react';
import { asyncComponent } from 'react-async-component';
export default asyncComponent({
resolve: () => System.import('./fatComponent.tsx')
});
\ No newline at end of file
import * as React from 'react'
import {Component} from 'react'
import {Link} from 'react-router-dom'
class Header extends Component {
render() {
return (
<div>
<h1>Header</h1>
<ul>
<li>
<Link to="/">Main</Link>
</li>
<li>
<Link to="/authors">Authors</Link>
</li>
<li>
<Link to="/articles">Articles</Link>
</li>
<li>
<Link to="/fatComponent">Fat Component</Link>
</li>
</ul>
</div>
)
}
}
export default Header;
\ No newline at end of file
import * as React from 'react'
import {Component} from 'react'
class Home extends Component {
render(){
return (
<div>
<p>
Main
</p>
</div>
)
}
}
export default Home;
\ No newline at end of file
import * as React from 'react'
import {Component} from 'react'
import {Route} from 'react-router-dom'
import Header from './components/header'
import Main from './components/home'
import AllAuthors from './components/asyncAuthors'
import AllArticles from './components/allArticles'
import FatComponent from './components/asyncFatComponent'
class Routes extends Component {
render(){
return <div>
<Header/>
<Route exact path="/" component={Main} />
<Route exact path="/authors" component={AllAuthors}/>
<Route exact path="/articles" component={AllArticles}/>
<Route exact path="/fatComponent" component={FatComponent}/>
</div>
}
}
export default Routes;
\ No newline at end of file
import * as express from 'express'
import {postgraphile} from 'postgraphile'
import render from './serverRender'
const IS_PRODUCTION: boolean = process.env.NODE_ENV === 'production';
const PORT: number = parseInt(process.env.PORT) || 8081;
const HOST: string = 'localhost';
const server = express();
server.use(postgraphile('postgres://postgres@localhost:15432/postgres','workshop',{
graphiql: true,
graphqlRoute: '/graphql'
}));
if (!IS_PRODUCTION){
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpack = require("webpack");
const webpackConfig = require("../../webpack.client.config");
const compiler = webpack(webpackConfig);
server.use(webpackDevMiddleware(compiler, {
publicPath: "/",
noInfo: true
}));
server.use(require("webpack-hot-middleware")(compiler));
}
server.get('*', (req: express.Request, res: express.Response) => {
const context = {};
render(req.url).then((html: string) => {
res.status(200);
res.end(html);
}).catch((e: Error)=> {
console.log('Error rendering: ',e);
res.status(500);
res.end();
});
});
server.listen(PORT,HOST,() => {
console.log(`listening on: ${HOST}:${PORT}`);
});
\ No newline at end of file
import * as React from "react";
import ApolloClient from "apollo-client";
import * as fetch from 'node-fetch'
import { ApolloProvider, renderToStringWithData } from 'react-apollo';
import HttpLink from 'apollo-link-http';
import { StaticRouter } from 'react-router';
import { InMemoryCache } from "apollo-cache-inmemory";
import { renderToString } from 'react-dom/server';
import { AsyncComponentProvider, createAsyncContext } from 'react-async-component';
import asyncBootstrapper from 'react-async-bootstrapper';
import Routes from '../common/routes';
export default function (url: string): Promise<string> {
const link = new HttpLink({
uri: 'http://localhost:8081/graphql'
});
const client = new ApolloClient({
ssrMode: true,
link,
cache: new InMemoryCache()
});
const routerContext = {};
const asyncContext = createAsyncContext();
const App = (
<AsyncComponentProvider asyncContext={asyncContext} >
<ApolloProvider client={client}>
<StaticRouter location={url} context={routerContext}>
<Routes />
</StaticRouter>
</ApolloProvider>
</AsyncComponentProvider>
);
return new Promise((resolve: (result: any) => void, reject: (error: any) => void) => {
asyncBootstrapper(App).then(() =>
renderToStringWithData(App)
.then((reactHtmlContent) => {
const asyncState = JSON.stringify(asyncContext.getState());
const initialState = JSON.stringify(client.extract()).replace(/</g, '\\u003c');
resolve(`<!DOCTYPE html>
<html>
<head>
<link rel="apple-touch-icon" sizes="57x57" href="/icon.png" />
</head>
<body>
<div id="react-root">${reactHtmlContent}</div>
<script>window.__APOLLO_STATE__=${initialState}</script>
<script>window.__ASYNC_STATE__=${asyncState}</script>
<script type="text/javascript" src="/vendor.js"></script>
<script type="text/javascript" src="/client.js"></script>
</body>
</html>`);
}).catch((reason: any) => {
reject(reason);
}));
});
}
\ No newline at end of file
declare module 'lodash.flowright';
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment