Skip to content

Commit 3498717

Browse files
Add mutations for create and update post, Simplify GetPosts mutation, Start work on CreatePost screen, Cleanup code and setup, Improve documentation
1 parent caad268 commit 3498717

File tree

16 files changed

+4219
-441
lines changed

16 files changed

+4219
-441
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
# React Mui WP GraphQl Example
22

3-
Example backend build with React and Material Design. Data is synced via GraphQl and Apollo from a WordPress server.
3+
Example backend build with React and Material Design.
4+
Reads data from a GraphQl API WordPress server with the WPGraphQL plugin.
45

5-
## How to run
6+
## Setup
67

7-
Install & Start server
8+
Install dependencies
89

910
```sh
1011
composer install
11-
cp .env.example .env
12+
npm install
1213
```
1314

1415
Create the database and fill details in `.env` file
15-
It is expected you have WP-CLI installed globally
16+
17+
```sh
18+
cp .env.example .env
19+
```
20+
21+
Setup server (This sets up the wordpress database with the expected configuration)
1622

1723
```sh
1824
./setup-server.sh
19-
./generate-data-on-server.sh
20-
wp server --host=localhost --port=3001
2125
```
2226

23-
Install the client dependencies and start react app
27+
## Start server & client
28+
29+
Start server and react app
2430

2531
```sh
26-
npm install
2732
npm start
2833
```
34+
35+
## Notes

bin/generate-data-on-server.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

bin/setup-server.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
#!/bin/bash
22

33
# Perform WP installation process.
4-
wp core install \
5-
--url="127.0.0.1:8001" \
4+
server/vendor/bin/wp core install \
5+
--url="localhost:3001" \
66
--title="WodaWordPress" \
77
--admin_user="test" \
88
--admin_email="test@woda.at" \
99
--admin_password="test"
1010

1111
# Update permalink structure
12-
wp option update permalink_structure '/%postname%'
12+
server/vendor/bin/wp option update permalink_structure '/%postname%'
13+
14+
# Set WpGraphQl Cors "Access-Control-Allow-Origin" header
15+
server/vendor/bin/wp option update wpgraphql_acao 'http://localhost:3000'
1316

1417
# Remove all posts, comments, and terms.
15-
wp site empty --yes
18+
server/vendor/bin/wp site empty --yes
19+
20+
# Generate data on server
21+
server/vendor/bin/wp post generate --count=100 --post_type=post

composer.json

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,54 @@
22
"name": "woda/react-mui-example-server",
33
"type": "project",
44
"license": "MIT",
5-
"description": "Server for React Material Design backend example",
5+
"description": "GraphQl server for react-mui-example",
66
"repositories": [
77
{
88
"type": "composer",
99
"url": "https://wpackagist.org",
1010
"only": ["wpackagist-plugin/*", "wpackagist-theme/*"]
11+
},
12+
{
13+
"type": "package",
14+
"package": {
15+
"name": "funkhaus/wp-graphql-cors",
16+
"type": "wordpress-plugin",
17+
"version": "1.1.0",
18+
"dist": {
19+
"url": "https://github.com/funkhaus/wp-graphql-cors/archive/v1.1.0.zip",
20+
"type": "zip"
21+
},
22+
"source": {
23+
"url": "https://github.com/funkhaus/wp-graphql-cors",
24+
"type": "git",
25+
"reference": "tree/v1.1.0"
26+
}
27+
}
1128
}
1229
],
1330
"require": {
14-
"php": ">=7.1",
31+
"php": ">=7.2",
1532
"composer/installers": "^1.8",
16-
"vlucas/phpdotenv": "^4.1.8",
33+
"funkhaus/wp-graphql-cors": "^1.1",
1734
"oscarotero/env": "^2.1",
1835
"roots/bedrock-autoloader": "^1.0",
1936
"roots/wordpress": "5.5",
2037
"roots/wp-config": "1.0.0",
2138
"roots/wp-password-bcrypt": "1.0.0",
39+
"valu/wp-graphql-offset-pagination": "^0.2.0",
40+
"vlucas/phpdotenv": "^4.1",
2241
"wp-graphql/wp-graphql": "^0.12.1",
42+
"wp-graphql/wp-graphql-acf": "^0.3.5",
2343
"wp-graphql/wp-graphql-jwt-authentication": "^0.4.1",
24-
"valu/wp-graphql-offset-pagination": "^0.2.0"
44+
"wpackagist-plugin/advanced-custom-fields": "^5.9"
2545
},
2646
"require-dev": {
27-
"squizlabs/php_codesniffer": "^3.5.6",
28-
"roave/security-advisories": "dev-master"
47+
"roave/security-advisories": "dev-master",
48+
"squizlabs/php_codesniffer": "^3.5",
49+
"wp-cli/wp-cli-bundle": "^2.4"
2950
},
3051
"config": {
52+
"sort-packages": true,
3153
"optimize-autoloader": true,
3254
"preferred-install": "dist",
3355
"vendor-dir": "server/vendor"
@@ -38,9 +60,12 @@
3860
"installer-paths": {
3961
"server/web/app/mu-plugins/{$name}/": [
4062
"type:wordpress-muplugin",
63+
"funkhaus/wp-graphql-cors",
64+
"valu/wp-graphql-offset-pagination",
4165
"wp-graphql/wp-graphql",
4266
"wp-graphql/wp-graphql-jwt-authentication",
43-
"valu/wp-graphql-offset-pagination"
67+
"wp-graphql/wp-graphql-acf",
68+
"wpackagist-plugin/advanced-custom-fields"
4469
],
4570
"server/web/app/plugins/{$name}/": ["type:wordpress-plugin"],
4671
"server/web/app/themes/{$name}/": ["type:wordpress-theme"]

0 commit comments

Comments
 (0)