All Projects → GomaGoma676 → nextjs-hasura-basic-lesson

GomaGoma676 / nextjs-hasura-basic-lesson

Licence: other
[Hasura基礎編] Nextjs+Hasura+Apollo Clientで学ぶモダンGraphQL Web開発 🚀

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to nextjs-hasura-basic-lesson

Fable.Jester
Fable bindings for jest and friends for delightful Fable testing.
Stars: ✭ 28 (-24.32%)
Mutual labels:  react-testing-library
cra-template-quickstart-redux
Opinionated quickstart Create React App template with Redux, React Testing Library and custom eslint configuration
Stars: ✭ 66 (+78.38%)
Mutual labels:  react-testing-library
graphql-to-sql
GraphQL model to SQL
Stars: ✭ 13 (-64.86%)
Mutual labels:  hasura-graphql
Jest Dom
🦉 Custom jest matchers to test the state of the DOM
Stars: ✭ 2,908 (+7759.46%)
Mutual labels:  react-testing-library
react-boilerplate
React 18, React-Router, Typescript, Vite, Babel 7, React-Testing-Library, Vitest
Stars: ✭ 27 (-27.03%)
Mutual labels:  react-testing-library
ui-kit
D2iQ UI Kit
Stars: ✭ 29 (-21.62%)
Mutual labels:  react-testing-library
Batteries-Included-Next.js
A starting boilerplate for a TS Next.js project with batteries included. Tailwind CSS for styling, Jest and React Testing Library working with path aliases and node-mock-http for API route testing.
Stars: ✭ 35 (-5.41%)
Mutual labels:  react-testing-library
tailwind-react-next.js-typescript-eslint-jest-starter
Starter template for building a project using React, Typescript, Next.js, Jest, TailwindCSS and ESLint.
Stars: ✭ 80 (+116.22%)
Mutual labels:  react-testing-library
nextjs-with-chakra-ui-boilerplate
Next.js with Chakra UI boilerplate. PWA ready with storybook and tests configured.
Stars: ✭ 48 (+29.73%)
Mutual labels:  react-testing-library
nextjs-complete-boilerplate
Next js 12.3.1 boilerplate with Styled Components, Jest, React Testing Library, Prettier, ESLint, Plop JS and more 🚀
Stars: ✭ 50 (+35.14%)
Mutual labels:  react-testing-library
hasura-node-monolith-example
Example of a monolithic web application using Hasura GraphQL Engine + Node.js + Next.js
Stars: ✭ 25 (-32.43%)
Mutual labels:  hasura-graphql
react-learning-resources
A curated list of resources to learn React and related web technologies as fast as possible.
Stars: ✭ 65 (+75.68%)
Mutual labels:  react-testing-library
sugui
UI Components library based on React, Styled Components and React Testing Library
Stars: ✭ 17 (-54.05%)
Mutual labels:  react-testing-library
react-movies-finder
React Movies finder is a React app to search movies and series using redux, redux-thunk, React Hooks, and Material UI
Stars: ✭ 27 (-27.03%)
Mutual labels:  react-testing-library
wargabantuwarga.com
Inisiatif warga untuk berbagi informasi seputar fasilitas kesehatan dan alat kesehatan untuk COVID-19.
Stars: ✭ 533 (+1340.54%)
Mutual labels:  react-testing-library
awesome-address-book
This project shows a basic address book built with ReactJS, Redux Toolkit and Typescript 📖
Stars: ✭ 20 (-45.95%)
Mutual labels:  react-testing-library
wongames
🎮 Ecommerce de jogos no estilo Steam. Desenvolvido com Next.js, TypeScript, GraphQL, etc.
Stars: ✭ 18 (-51.35%)
Mutual labels:  react-testing-library
jsdom-testing-mocks
A set of tools for emulating browser behavior in jsdom environment
Stars: ✭ 37 (+0%)
Mutual labels:  react-testing-library
react-simple-boilerplate
Simple React Boilerplate with Webpack, Github Actions, Scss, Lazy Loading etc....
Stars: ✭ 38 (+2.7%)
Mutual labels:  react-testing-library
IMO-Maritime-Single-Window
An IMO coordinated project developing a generic Maritime Single Window.
Stars: ✭ 18 (-51.35%)
Mutual labels:  msw

Project setup :

・Nextjs

・TypeScript

・Apollo Client

・React-testing-library

・Next-page-tester

・Tailwind CSS

・Mock Service Worker(MSW)

1. Nextjs Project 新規作成

1-1. yarn install *インストールしていない場合

npm install --global yarn
yarn --version

1-2. create-next-app

npx create-next-app .

Node.js version 10.13以降が必要です。 -> ターミナル node -vでver確認出来ます。

1-3. Apollo Client + heroicons + cross-fetch のインストール

yarn add @apollo/client graphql @apollo/react-hooks cross-fetch @heroicons/react

1-4. React-Testing-Library + MSW + next-page-tester のインストール

1-5. Project folder 直下に".babelrc"ファイルを作成して下記設定を追加

touch .babelrc
    {
        "presets": ["next/babel"]
    }

1-6. package.json に jest の設定を追記

    "jest": {
        "testPathIgnorePatterns": [
            "<rootDir>/.next/",
            "<rootDir>/node_modules/"
        ],
        "moduleNameMapper": {
            "\\.(css)$": "<rootDir>/node_modules/jest-css-modules"
        }
    }

1-7. package.jsonに test scriptを追記

    "scripts": {
        ...
        "test": "jest --env=jsdom --verbose"
    },

1-8. prettierの設定 : settingsでRequire Config + Format On Saveにチェック

touch .prettierrc
    {
        "singleQuote": true,
        "semi": false
    }

2. TypeScript の導入

https://nextjs.org/learn/excel/typescript/create-tsconfig

2-1. 空のtsconfig.json作成

touch tsconfig.json

2-2. 必要moduleのインストール

yarn add -D typescript @types/[email protected] @types/node

2-3. 開発server起動

yarn dev

2-4. _app.js, index.js -> tsx へ拡張子変更

2-5. AppProps型追記

    import { AppProps } from 'next/app'

    function MyApp({ Component, pageProps }: AppProps) {
        return <Component {...pageProps} />
    }

    export default MyApp

3. Tailwind CSS の導入

https://tailwindcss.com/docs/guides/nextjs

3-1. 必要moduleのインストール

yarn add tailwindcss@latest postcss@latest autoprefixer@latest

3-2. tailwind.config.js, postcss.config.jsの生成

npx tailwindcss init -p

3-3. tailwind.config.jsのcontent設定追加

module.exports = {
    content: [
        "./pages/**/*.{js,ts,jsx,tsx}",
        "./components/**/*.{js,ts,jsx,tsx}",
    ],
    darkMode: false,
    theme: {
        extend: {},
    },
    variants: {
        extend: {},
    },
    plugins: [],
}

3-4. globals.cssの編集

@tailwind base;
@tailwind components;
@tailwind utilities;

4. Test動作確認

4-1. __tests__フォルダとHome.test.tsxファイルの作成

import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import Home from '../pages/index'

it('Should render title text', () => {
  render(<Home />)
  expect(screen.getByText('Next.js!')).toBeInTheDocument()
})

4-2. yarn test -> テストがPASSするか確認

 PASS  __tests__/Home.test.tsx
  ✓ Should render hello text (20 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.728 s, estimated 2 s

5. GraphQL codegen

5-1. install modules + init

yarn add -D @graphql-codegen/cli
yarn graphql-codegen init
yarn
yarn add -D @graphql-codegen/typescript

5-2. add queries in queries/queries.ts file

5-3. generate types automatically

yarn gen-types
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].