Git Product home page Git Product logo

www-template's Introduction

www-template

CircleCI Commitizen friendly CodeFactor

Development

Clone the repository and run:

# install dependencies
yarn

# start development server
yarn dev

The development runs both the Express server and the Webpack devServer concurrently, proxying the Express server to port 3001. Go to http://localhost:3000 to view the application.

Any changes to server-side code will restart the server (via nodemon) and any changes to client-side code will auto-change on the browser (via react-refresh.)

GraphQL

Modules

We use GraphQL Modules in order to separate the GraphQL schema implementation into small, reusable, easy-to-implement and easy-to-test pieces with the possibility to extract them easily if necessary in the future.

Each module is made up of a schema, resolvers and their datasource which makes the relevant calls to external apis.

In order to correctly type the resolvers, once the schema has changed, run yarn generate to create typings for the module.

Apollo Server

The modules are collated in src/server/graphql/index and passed to an instance of Apollo Server. When this server is started (as part of the overall Express server) the GraphQL playground is available in dev environment at /graphql.

Apollo Client (Server)

The server-side instance of Apollo Client is initiated in src/server/routes/application. Using SchemaLink allows performing GraphQL operations on the provided schema rather than making network calls when loading the page.

Apollo Client (Browser)

The client-side instance of Apollo Client is initiated in src/client/index. The client is initiated with the value of window.__APOLLO_STATE__ which is passed to the html via src/server/routes/application.

Queries

Queries are made within React components as and when they are required. For example:

const GET_ME = gql`
  query me {
    me {
      firstName
    }
  }
`;

This query knows which resolver query to call and we want just the firstName to be returned. We call that query within the React component:

const { error, loading, data } = useQuery(GET_ME);

if (loading) return <p>Loading...</p>;
if (error) return <p>Error :(</p>;

return <p>{data.me.firstName}</p>

www-template's People

Contributors

corbpaul avatar renovate[bot] avatar

Watchers

 avatar  avatar

www-template's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error near ", ],

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update all (@apollo/client, apollo-server-caching, apollo-server-express, express-winston, graphql, graphql-import-node, graphql-modules, hbs, react-router-dom, serialize-javascript, theme-ui, winston)
  • chore(deps): update dev, build & server dependencies (@babel/core, @babel/preset-env, @babel/preset-react, @babel/preset-typescript, @pmmmwh/react-refresh-webpack-plugin, @testing-library/jest-dom, @testing-library/react, @testing-library/react-hooks, @types/compression, @types/dotenv-safe, @types/express, @types/hbs, @types/jest-axe, @types/react, @types/react-dom, @types/react-helmet, @types/react-router-dom, @types/serialize-javascript, @types/webpack-dev-server, @types/webpack-manifest-plugin, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, babel-loader, clean-webpack-plugin, concurrently, eslint-config-prettier, eslint-plugin-cypress, eslint-plugin-prettier, eslint-plugin-react, husky, jest, lint-staged, nodemon, prettier, react-refresh, ts-jest, ts-node, tsconfig-paths, type-coverage, typescript, typescript-coverage-report, webpack-cli, webpack-dev-server, webpack-manifest-plugin, webpack-merge)
  • chore(deps): update all to v18 (major) (react, react-dom)
  • chore(deps): update cimg/node docker tag to v22
  • chore(deps): update dependency @testing-library/react to v16
  • chore(deps): update dependency dotenv-safe to v9
  • chore(deps): update dependency graphql to v16
  • chore(deps): update dependency graphql-modules to v2
  • chore(deps): update dependency lint-staged to v12
  • chore(deps): update dependency react-router-dom to v6
  • chore(deps): update dependency typescript-coverage-report to v1
  • chore(deps): update dev, build & server dependencies to v13 (major) (@testing-library/react, lint-staged)
  • chore(deps): update dev, build & server dependencies to v14 (major) (@testing-library/react, lint-staged)
  • chore(deps): update dev, build & server dependencies to v15 (major) (@testing-library/react, lint-staged)
  • chore(deps): update dev, build & server dependencies to v18 (major) (@types/react, @types/react-dom)
  • chore(deps): update dev, build & server dependencies to v28 (major) (@types/jest, jest, ts-jest)
  • chore(deps): update dev, build & server dependencies to v29 (major) (@types/jest, jest, ts-jest)
  • chore(deps): update dev, build & server dependencies to v3 (major) (eslint-plugin-cypress, nodemon, prettier)
  • chore(deps): update dev, build & server dependencies to v5 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint-plugin-prettier, rimraf, typescript, webpack-cli, webpack-dev-server, webpack-manifest-plugin)
  • chore(deps): update dev, build & server dependencies to v6 (major) (@testing-library/jest-dom, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, jest-axe)
  • chore(deps): update dev, build & server dependencies to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser, concurrently, jest-axe)
  • chore(deps): update dev, build & server dependencies to v8 (major) (@testing-library/react-hooks, concurrently, eslint, husky, jest-axe)
  • chore(deps): update dev, build & server dependencies to v9 (major) (babel-loader, eslint, eslint-config-prettier, husky, jest-axe)
  • chore(deps): update heroku orb to v2
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • heroku 1.2.6
  • cimg/node 16.6.0
npm
package.json
  • @apollo/client 3.3.21
  • apollo-server-caching 3.0.1
  • apollo-server-express 3.1.1
  • compression 1.7.4
  • dotenv-safe 8.2.0
  • express 4.17.1
  • express-winston 4.1.0
  • graphql 15.5.1
  • graphql-import-node 0.0.4
  • graphql-modules 1.4.3
  • hbs 4.1.2
  • react 17.0.2
  • react-dom 17.0.2
  • react-helmet 6.1.0
  • react-router-dom 5.2.0
  • serialize-javascript 6.0.0
  • theme-ui 0.10.0
  • winston 3.3.3
  • @apollo/react-testing 4.0.0
  • @babel/core 7.15.0
  • @babel/preset-env 7.15.0
  • @babel/preset-react 7.14.5
  • @babel/preset-typescript 7.15.0
  • @pmmmwh/react-refresh-webpack-plugin 0.4.3
  • @testing-library/jest-dom 5.14.1
  • @testing-library/react 12.0.0
  • @testing-library/react-hooks 7.0.1
  • @types/compression 1.7.1
  • @types/dotenv-safe 8.1.2
  • @types/express 4.17.13
  • @types/hbs 4.0.1
  • @types/jest 26.0.24
  • @types/jest-axe 3.5.2
  • @types/react 17.0.17
  • @types/react-dom 17.0.9
  • @types/react-helmet 6.1.2
  • @types/react-router-dom 5.1.8
  • @types/serialize-javascript 5.0.1
  • @types/webpack-dev-server 3.11.5
  • @types/webpack-manifest-plugin 3.0.5
  • @typescript-eslint/eslint-plugin 4.29.1
  • @typescript-eslint/parser 4.29.1
  • babel-loader 8.2.2
  • clean-webpack-plugin 4.0.0-alpha.0
  • concurrently 6.2.1
  • copyfiles 2.4.1
  • cz-conventional-changelog 3.3.0
  • eslint 7.32.0
  • eslint-config-prettier 8.3.0
  • eslint-plugin-cypress 2.11.3
  • eslint-plugin-prettier 3.4.0
  • eslint-plugin-react 7.24.0
  • husky 7.0.1
  • jest 27.0.6
  • jest-axe 5.0.1
  • jest-transform-graphql 2.1.0
  • lint-staged 11.1.2
  • nodemon 2.0.12
  • prettier 2.3.2
  • react-refresh 0.10.0
  • rimraf 3.0.2
  • ts-jest 27.0.4
  • ts-node 10.2.0
  • tsconfig-paths 3.10.1
  • type-coverage 2.18.0
  • typescript 4.3.5
  • typescript-coverage-report 0.6.0
  • webpack 5.50.0
  • webpack-cli 4.7.2
  • webpack-dev-server 3.11.2
  • webpack-manifest-plugin 4.0.2
  • webpack-merge 5.8.0
nvm
.nvmrc

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.