Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 setup apollo client for ssr with nextjs #51

Merged
merged 19 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-01-26T13:37:41.662Z"
"x-generation-date": "2024-01-26T18:39:20.847Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down
8 changes: 8 additions & 0 deletions docs/general-usage.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
### Type generation

###### REST

When updating a schema in Strapi, you have to run `npm run generateTypes` in the root directory to generate the proper types for the frontend.

> This uses Strapi's official [documentation plugin](https://docs.strapi.io/dev-docs/plugins/documentation) to generate documentation matching the [OpenAPI specification](https://swagger.io/specification/). It then uses the [@openapi-typescript](https://www.npmjs.com/package/openapi-typescript) package to generate the typescript types.
>
> The generated documentation can be found at [http://localhost:1337/documentation/v1.0.0](http://localhost:1337/documentation/v1.0.0) when running the dev server.

###### GraphQL

If you're using GraphQL, then you need to run `npm run compile` from `/frontend` whenever you update a schema or define a new graphQL request in the code.

> [https://www.apollographql.com/docs/react/development-testing/static-typing/](https://www.apollographql.com/docs/react/development-testing/static-typing/)

### Strapi First time boot

Goto Settings > Users & Permissions plugin > Roles > Public > Article, and enable `find` and `findOne`
Expand Down
1 change: 0 additions & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Database API URL
API_URL=http://localhost:1337/api/
HOST_URL=http://localhost:1337
1 change: 0 additions & 1 deletion frontend/.env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Heroku Database API
API_URL=https://small-sat-lab-6ad3da13947b.herokuapp.com/api/
HOST_URL=https://small-sat-lab-6ad3da13947b.herokuapp.com
3 changes: 2 additions & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": ["eslint:recommended", "next/core-web-vitals", "prettier"]
"extends": ["eslint:recommended", "next/core-web-vitals", "prettier"],
"ignorePatterns": ["src/__generated__/*"]
}
3 changes: 3 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ignore artifacts:
build
coverage

# Ignore graphQL codegen generated types
src/__generated__/*
21 changes: 21 additions & 0 deletions frontend/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { CodegenConfig } from "@graphql-codegen/cli";

const HOST_URL = "http://localhost:1337";

const config: CodegenConfig = {
schema: HOST_URL + "/graphql",
// this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure
documents: ["src/**/*.{ts,tsx}"],
generates: {
"./src/__generated__/": {
preset: "client",
plugins: [],
presetConfig: {
gqlTagName: "gql",
},
},
},
ignoreNoDocuments: true,
};

export default config;
Loading
Loading