Skip to content

Commit 529073b

Browse files
committed
Implement cra-ts example
1 parent ddd41df commit 529073b

25 files changed

+410
-315
lines changed

examples/cra-ts/.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["react-app"],
3+
"plugins": ["babel-plugin-import-graphql"]
4+
}

examples/cra-ts/codegen.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
schema: ../docs/schema.graphql
2+
documents: src/**/*.graphql
3+
generates:
4+
./src/codegenTypedDocuments.d.ts:
5+
plugins:
6+
- apollo-typed-documents/lib/codegenTypedDocuments
7+
config:
8+
typesModule: "@codegen-types"
9+
./src/codegenTypes.d.ts:
10+
plugins:
11+
- add: 'declare module "@codegen-types" {'
12+
- add:
13+
placement: append
14+
content: "}"
15+
- typescript
16+
- typescript-operations
17+
./src/apolloMock.js:
18+
plugins:
19+
- add: "/* eslint-disable */"
20+
- apollo-typed-documents/lib/codegenApolloMock

examples/cra-ts/config-overrides.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { override, useBabelRc } = require("customize-cra");
2+
3+
module.exports = override(useBabelRc());

examples/cra-ts/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,29 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@apollo/react-hooks": "^3.1.5",
7+
"@apollo/react-testing": "^3.1.4",
68
"@testing-library/jest-dom": "^4.2.4",
79
"@testing-library/react": "^9.3.2",
810
"@testing-library/user-event": "^7.1.2",
911
"@types/jest": "^24.0.0",
1012
"@types/node": "^12.0.0",
1113
"@types/react": "^16.9.0",
1214
"@types/react-dom": "^16.9.0",
15+
"babel-plugin-import-graphql": "^2.7.0",
16+
"customize-cra": "^0.9.1",
1317
"react": "^16.13.1",
18+
"react-app-rewired": "^2.1.5",
1419
"react-dom": "^16.13.1",
1520
"react-scripts": "3.4.1",
1621
"typescript": "~3.7.2"
1722
},
1823
"scripts": {
19-
"start": "react-scripts start",
20-
"build": "react-scripts build",
21-
"test": "react-scripts test",
22-
"eject": "react-scripts eject"
24+
"start": "react-app-rewired start",
25+
"build": "react-app-rewired build",
26+
"test": "react-app-rewired test",
27+
"eject": "react-scripts eject",
28+
"generate": "../../node_modules/@graphql-codegen/cli/bin.js"
2329
},
2430
"eslintConfig": {
2531
"extends": "react-app"

examples/cra-ts/public/index.html

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,10 @@
99
name="description"
1010
content="Web site created using create-react-app"
1111
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
14-
manifest.json provides metadata used when your web app is installed on a
15-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16-
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
19-
Notice the use of %PUBLIC_URL% in the tags above.
20-
It will be replaced with the URL of the `public` folder during the build.
21-
Only files inside the `public` folder can be referenced from the HTML.
22-
23-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24-
work correctly both with client-side routing and a non-root public URL.
25-
Learn how to configure a non-root public URL by running `npm run build`.
26-
-->
2712
<title>React App</title>
2813
</head>
2914
<body>
3015
<noscript>You need to enable JavaScript to run this app.</noscript>
3116
<div id="root"></div>
32-
<!--
33-
This HTML file is a template.
34-
If you open it directly in the browser, you will see an empty page.
35-
36-
You can add webfonts, meta tags, or analytics to this file.
37-
The build step will place the bundled scripts into the <body> tag.
38-
39-
To begin the development, run `npm start` or `yarn start`.
40-
To create a production bundle, use `npm run build` or `yarn build`.
41-
-->
4217
</body>
4318
</html>

examples/cra-ts/public/logo192.png

-5.22 KB
Binary file not shown.

examples/cra-ts/public/logo512.png

-9.44 KB
Binary file not shown.

examples/cra-ts/public/manifest.json

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

examples/cra-ts/public/robots.txt

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

examples/cra-ts/src/App.css

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

0 commit comments

Comments
 (0)