在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:yatsu/react-apollo-koa-example开源软件地址:https://github.com/yatsu/react-apollo-koa-example开源编程语言:JavaScript 96.0%开源软件介绍:react-apollo-koa-exampleAn example web app using React, Apollo (GraphQL), Koa v.2. This project was generated by create-react-app and is not ejected. Some settings are overwritten on runtime though. passport
branch uses Passport to integrate authentication with
social services such as Google+, Facebook, etc., whereas SetupInstall required packages. % yarn Copy Copy UsageLaunch the API server: % yarn run server Launch the development web server which serves the static client-side files: % yarn start Open the URL (default: Frameworks/LibrariesClient-side
The application code was generated by create-react-app. See package.json for more information. Server-side (the API server)See package.json for more information. The API server does not use DB and stores data on memory. All changes will be cleared when you stop the server. TestsRepo and code management
GraphQL/ApolloPersisted QueriesGraphQL querires, mutations and subscriptions are defined in You can enable persisted queries by modifying {
"persistedQueries": true
} You need to generate % yarn run persistgraphql Read the following article to know about persisted queries. SubscriptionsThis example project uses subscriptions. Select "GraphQL Subscription" tab in the header to see it. Read the following article to know about subscriptions. AuthenticationJWT access token and refresh token are used to authenticate a client.
The access token is automatically refreshed by WebClient and Apollo client (including GraphQL subscription). When the refresh token is expired, the user will be automatically signed out. The WebSocket connection will also be authenticated with a JWT access token. It will be reconnected on signing in/out to do the authentication. There are two types of connection, authenticated and unauthenticated. You can set the expiration on server-side by editing e.g.: ACCESS_TOKEN_EXPIRES_IN=10s
REFRESH_TOKEN_EXPIRES_IN=2h You need to sign out and sign in again to apply the new expiration. It is also possible to set them in client-side localStorage if the server is running on debugging mode. Set { "X-ACCESS-TOKEN-EXPIRES-IN": "10s", "X-REFRESH-TOKEN-EXPIRES-IN": "2h" } Setting StorybookThis project uses React Storybook. to develop and check presentational components. Launch the Storybook server: % yarn run storybook StoryShots is also used to enable
snapshot tests.
When you modify a component and the render result is changed, Jest reports an
error. If the shown result is intended, press Code OrganizationRedux actions, reducers and logic are managed by
Ducks rules in Tests are stored in Git HooksGit hooks are managed by Husky.
When you run If you have a problem, you can create them manually. % node node_modules/husky/bin/install.js Our Git hooks are defined in |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论