Skip to content

Commit

Permalink
update script and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aderaaij committed Oct 17, 2020
1 parent e12762a commit 5658e65
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# A statically generated blog example using Next.js and WordPress
# NextJS client for (headless) WordPress

A NextJS starter for WordPress with WPGraphQL based on the excellent [NextJS WordPress example](https://github.com/vercel/next.js/tree/canary/examples/cms-wordpress), featuring:
A NextJS starter for WordPress installations with WPGraphQL, including TypeScript and dynamic type generating with graphql-codegen

- NextJS
- GraphQL (Requires WordPress installation)
- TypeScript
- Prettier, ESLint, etc
## Features

## Generating Types
- Works out of the box with any WordPress installation including WPGraphQL
- TypeScript and dynamic type generating with graphql-codegen
- Prettier, ESLint, Husky and Lint Staged
- Tailwind CSS

By running `yarn generate` you can generate types right from your WPGraphQL schema and the operations defined in `.src/graphql/**/*`. You can see and updat the confing in the `codegen.yml` file in the root of your project. The endpoint is loaded from the `.env.local` to
## Installation

1. Clone this repository to your machine
2. Run `yarn install`
3. Rename `.env.local.example` to `env.local` file
4. Add your `WORDPRESS_API_URL` url to your `.env.local` file
5. Run `yarn generate:codegen` to generate types\*
6. Run `yarn dev` to start a local server and start developing

- \*Running graphql-codegen on the WPGraphQL schema generates two invalid enum types, `2048X2048` and `1536X1536`. These are invalid because they start numeric. There is currently an issue opened about this right here: https://github.com/dotansimha/graphql-code-generator/issues/4834.

### Generating Types

By running `yarn generate:codegen` you can generate types right from your WPGraphQL schema and the operations defined in `.src/graphql/**/*`. You can see and updat the confing in the `codegen.yml` file in the root of your project. The endpoint is loaded from the `.env.local` file.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"dev": "next",
"build": "next build",
"start": "next start",
"generate": "DOTENV_CONFIG_PATH=.env.local graphql-codegen -r dotenv/config",
"generate:watch": "graphql-codegen -w -r dotenv/config",
"generate:codegen": "DOTENV_CONFIG_PATH=.env.local graphql-codegen -r dotenv/config",
"generate:codegen:watch": "graphql-codegen -w -r dotenv/config",
"lint": "eslint --fix .",
"type-check": "tsc --noEmit",
"prettier": "prettier --write"
Expand Down

1 comment on commit 5658e65

@vercel
Copy link

@vercel vercel bot commented on 5658e65 Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.