From 13d8ea5c2824f8fb6ffa781be1b4632c7b9641f8 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sun, 3 Dec 2023 03:47:10 +0800 Subject: [PATCH] feat: upgrade graphql-starter to Next.js v14 Issue #601 --- starters/graphql-starter/.env.example | 15 ++-- starters/graphql-starter/.eslintrc.json | 2 +- starters/graphql-starter/.gitignore | 16 ++-- starters/graphql-starter/.nvmrc | 1 + starters/graphql-starter/.prettierignore | 18 +++++ starters/graphql-starter/.prettierrc.json | 4 + .../components/PreviewAlert.tsx | 30 +++++++ .../{node--article.tsx => drupal/Article.tsx} | 20 ++--- .../ArticleTeaser.tsx} | 24 +++--- .../BasicPage.tsx} | 8 +- .../graphql-starter/components/layout.tsx | 6 +- .../components/preview-alert.tsx | 28 ------- starters/graphql-starter/lib/drupal.ts | 22 +++--- starters/graphql-starter/next-env.d.ts | 5 -- starters/graphql-starter/next.config.js | 10 ++- starters/graphql-starter/package.json | 30 +++---- starters/graphql-starter/pages/[...slug].tsx | 78 ++++++++++--------- starters/graphql-starter/pages/_app.tsx | 5 +- starters/graphql-starter/pages/_document.tsx | 13 ++++ .../graphql-starter/pages/api/exit-preview.ts | 7 +- starters/graphql-starter/pages/api/preview.ts | 7 +- .../graphql-starter/pages/api/revalidate.ts | 4 +- starters/graphql-starter/pages/index.tsx | 78 +++++++++---------- starters/graphql-starter/tailwind.config.js | 14 ---- starters/graphql-starter/tailwind.config.ts | 18 +++++ starters/graphql-starter/tsconfig.json | 10 ++- starters/graphql-starter/types/index.d.ts | 4 +- 27 files changed, 266 insertions(+), 211 deletions(-) create mode 100644 starters/graphql-starter/.nvmrc create mode 100644 starters/graphql-starter/.prettierignore create mode 100644 starters/graphql-starter/.prettierrc.json create mode 100644 starters/graphql-starter/components/PreviewAlert.tsx rename starters/graphql-starter/components/{node--article.tsx => drupal/Article.tsx} (68%) rename starters/graphql-starter/components/{node--article--teaser.tsx => drupal/ArticleTeaser.tsx} (66%) rename starters/graphql-starter/components/{node--basic-page.tsx => drupal/BasicPage.tsx} (69%) delete mode 100644 starters/graphql-starter/components/preview-alert.tsx delete mode 100644 starters/graphql-starter/next-env.d.ts create mode 100644 starters/graphql-starter/pages/_document.tsx delete mode 100644 starters/graphql-starter/tailwind.config.js create mode 100644 starters/graphql-starter/tailwind.config.ts diff --git a/starters/graphql-starter/.env.example b/starters/graphql-starter/.env.example index f4e26b94..f0a9bcf3 100644 --- a/starters/graphql-starter/.env.example +++ b/starters/graphql-starter/.env.example @@ -1,10 +1,15 @@ # See https://next-drupal.org/docs/environment-variables -NEXT_PUBLIC_DRUPAL_BASE_URL=https://dev.next-drupal.org -NEXT_IMAGE_DOMAIN=dev.next-drupal.org + +# Required +NEXT_PUBLIC_DRUPAL_BASE_URL=https://site.example.com +NEXT_IMAGE_DOMAIN=site.example.com # Authentication -DRUPAL_CLIENT_ID= -DRUPAL_CLIENT_SECRET= +DRUPAL_CLIENT_ID=Retrieve this from /admin/config/services/consumer +DRUPAL_CLIENT_SECRET=Retrieve this from /admin/config/services/consumer + +# Required for Preview Mode +DRUPAL_PREVIEW_SECRET=Retrieve this from /admin/config/services/next # Required for On-demand Revalidation -DRUPAL_REVALIDATE_SECRET=secret \ No newline at end of file +DRUPAL_REVALIDATE_SECRET=Retrieve this from /admin/config/services/next diff --git a/starters/graphql-starter/.eslintrc.json b/starters/graphql-starter/.eslintrc.json index abd5579b..7c1a3add 100644 --- a/starters/graphql-starter/.eslintrc.json +++ b/starters/graphql-starter/.eslintrc.json @@ -1,4 +1,4 @@ { - "extends": "next", + "extends": "next/core-web-vitals", "root": true } diff --git a/starters/graphql-starter/.gitignore b/starters/graphql-starter/.gitignore index 78adc9ed..081b7c17 100644 --- a/starters/graphql-starter/.gitignore +++ b/starters/graphql-starter/.gitignore @@ -4,6 +4,7 @@ /node_modules /.pnp .pnp.js +.yarn/install-state.gz # testing /coverage @@ -11,7 +12,6 @@ # next.js /.next/ /out/ -.next # production /build @@ -20,19 +20,21 @@ .DS_Store *.pem +# IDE files +/.idea +/.vscode + # debug npm-debug.log* yarn-debug.log* yarn-error.log* -lerna-debug.log* # local env files -.env.local -.env.development.local -.env.test.local -.env.production.local +.env*.local # vercel .vercel -/certificates/* \ No newline at end of file +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/starters/graphql-starter/.nvmrc b/starters/graphql-starter/.nvmrc new file mode 100644 index 00000000..9a2a0e21 --- /dev/null +++ b/starters/graphql-starter/.nvmrc @@ -0,0 +1 @@ +v20 diff --git a/starters/graphql-starter/.prettierignore b/starters/graphql-starter/.prettierignore new file mode 100644 index 00000000..03c8a68b --- /dev/null +++ b/starters/graphql-starter/.prettierignore @@ -0,0 +1,18 @@ +# Ignore everything. +/* + +# Format most files in the root directory. +!/*.js +!/*.ts +!/*.md +!/*.json +# But ignore some. +/package.json +/package-lock.json +/CHANGELOG.md + +# Don't ignore these nested directories. +!/app +!/components +!/lib +!/pages diff --git a/starters/graphql-starter/.prettierrc.json b/starters/graphql-starter/.prettierrc.json new file mode 100644 index 00000000..3c60a7b5 --- /dev/null +++ b/starters/graphql-starter/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "semi": false, + "trailingComma": "es5" +} diff --git a/starters/graphql-starter/components/PreviewAlert.tsx b/starters/graphql-starter/components/PreviewAlert.tsx new file mode 100644 index 00000000..abca6a68 --- /dev/null +++ b/starters/graphql-starter/components/PreviewAlert.tsx @@ -0,0 +1,30 @@ +import { useEffect, useState } from "react" +import { useRouter } from "next/router" + +export function PreviewAlert() { + const router = useRouter() + const isPreview = router.isPreview + const [showPreviewAlert, setShowPreviewAlert] = useState(false) + + useEffect(() => { + setShowPreviewAlert(isPreview && window.top === window.self) + }, [isPreview]) + + if (!showPreviewAlert) { + return null + } + + return ( +
+

+ This page is a preview.{" "} + +

+
+ ) +} diff --git a/starters/graphql-starter/components/node--article.tsx b/starters/graphql-starter/components/drupal/Article.tsx similarity index 68% rename from starters/graphql-starter/components/node--article.tsx rename to starters/graphql-starter/components/drupal/Article.tsx index fba58340..2e9a05a3 100644 --- a/starters/graphql-starter/components/node--article.tsx +++ b/starters/graphql-starter/components/drupal/Article.tsx @@ -1,13 +1,12 @@ import Image from "next/image" +import { formatDate } from "@/lib/utils" +import type { NodeArticle } from "@/types" -import { formatDate } from "lib/utils" -import { Article } from "types" - -interface NodeArticleProps { - node: Article +interface ArticleProps { + node: NodeArticle } -export function NodeArticle({ node, ...props }: NodeArticleProps) { +export function Article({ node, ...props }: ArticleProps) { return (

{node.title}

@@ -21,18 +20,19 @@ export function NodeArticle({ node, ...props }: NodeArticleProps) { - {formatDate(node.created)} {node.image && ( -
+
{node.title}
)} {node.body?.processed && (
)} diff --git a/starters/graphql-starter/components/node--article--teaser.tsx b/starters/graphql-starter/components/drupal/ArticleTeaser.tsx similarity index 66% rename from starters/graphql-starter/components/node--article--teaser.tsx rename to starters/graphql-starter/components/drupal/ArticleTeaser.tsx index ac3baf86..ed88aca0 100644 --- a/starters/graphql-starter/components/node--article--teaser.tsx +++ b/starters/graphql-starter/components/drupal/ArticleTeaser.tsx @@ -1,17 +1,16 @@ import Image from "next/image" import Link from "next/link" +import { formatDate } from "@/lib/utils" +import type { NodeArticle } from "@/types" -import { formatDate } from "lib/utils" -import { Article } from "types" - -interface NodeArticleTeaserProps { - node: Partial
+interface ArticleTeaserProps { + node: Partial } -export function NodeArticleTeaser({ node, ...props }: NodeArticleTeaserProps) { +export function ArticleTeaser({ node, ...props }: ArticleTeaserProps) { return (
- +

{node.title}

@@ -21,20 +20,15 @@ export function NodeArticleTeaser({ node, ...props }: NodeArticleTeaserProps) { {node.author.displayName} ) : null} - - {formatDate(node.created)} + {node.created && - {formatDate(node.created)}}
{node.image && (
- {node.title} +
)} Read article diff --git a/starters/graphql-starter/components/node--basic-page.tsx b/starters/graphql-starter/components/drupal/BasicPage.tsx similarity index 69% rename from starters/graphql-starter/components/node--basic-page.tsx rename to starters/graphql-starter/components/drupal/BasicPage.tsx index d40139d2..b4bc2ed6 100644 --- a/starters/graphql-starter/components/node--basic-page.tsx +++ b/starters/graphql-starter/components/drupal/BasicPage.tsx @@ -1,10 +1,10 @@ -import { Page } from "types" +import type { NodePage } from "@/types" -interface NodeBasicPageProps { - node: Page +interface BasicPageProps { + node: NodePage } -export function NodeBasicPage({ node, ...props }: NodeBasicPageProps) { +export function BasicPage({ node, ...props }: BasicPageProps) { return (

{node.title}

diff --git a/starters/graphql-starter/components/layout.tsx b/starters/graphql-starter/components/layout.tsx index ea7ce17e..672d0b48 100644 --- a/starters/graphql-starter/components/layout.tsx +++ b/starters/graphql-starter/components/layout.tsx @@ -1,8 +1,8 @@ import Link from "next/link" +import { PreviewAlert } from "@/components/PreviewAlert" +import type { ReactNode } from "react" -import { PreviewAlert } from "components/preview-alert" - -export function Layout({ children }) { +export function Layout({ children }: { children: ReactNode }) { return ( <> diff --git a/starters/graphql-starter/components/preview-alert.tsx b/starters/graphql-starter/components/preview-alert.tsx deleted file mode 100644 index 54c38803..00000000 --- a/starters/graphql-starter/components/preview-alert.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import * as React from "react" -import { useRouter } from "next/router" - -export function PreviewAlert() { - const { isPreview } = useRouter() - const [showPreviewAlert, setShowPreviewAlert] = React.useState(false) - - React.useEffect(() => { - setShowPreviewAlert(isPreview && window.top === window.self) - }, [isPreview]) - - if (!showPreviewAlert) { - return null - } - - return ( -
-

- This page is a preview.{" "} - {/* eslint-disable @next/next/no-html-link-for-pages */} - - Click here - {" "} - to exit preview mode. -

-
- ) -} diff --git a/starters/graphql-starter/lib/drupal.ts b/starters/graphql-starter/lib/drupal.ts index 5f3baaaf..f191e1b3 100644 --- a/starters/graphql-starter/lib/drupal.ts +++ b/starters/graphql-starter/lib/drupal.ts @@ -1,15 +1,17 @@ import { DrupalClient } from "next-drupal" -export const drupal = new DrupalClient( - process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, - { - previewSecret: process.env.DRUPAL_PREVIEW_SECRET, - auth: { - clientId: process.env.DRUPAL_CLIENT_ID, - clientSecret: process.env.DRUPAL_CLIENT_SECRET, - }, - } -) +const baseUrl: string = process.env.NEXT_PUBLIC_DRUPAL_BASE_URL || "" +const clientId = process.env.DRUPAL_CLIENT_ID || "" +const clientSecret = process.env.DRUPAL_CLIENT_SECRET || "" +const previewSecret = process.env.DRUPAL_PREVIEW_SECRET + +export const drupal = new DrupalClient(baseUrl, { + auth: { + clientId, + clientSecret, + }, + previewSecret, +}) export const graphqlEndpoint = drupal.buildUrl("/graphql") diff --git a/starters/graphql-starter/next-env.d.ts b/starters/graphql-starter/next-env.d.ts deleted file mode 100644 index 4f11a03d..00000000 --- a/starters/graphql-starter/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/starters/graphql-starter/next.config.js b/starters/graphql-starter/next.config.js index d671944a..0a7fabac 100644 --- a/starters/graphql-starter/next.config.js +++ b/starters/graphql-starter/next.config.js @@ -1,7 +1,15 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + reactStrictMode: true, images: { - domains: [process.env.NEXT_IMAGE_DOMAIN], + remotePatterns: [ + { + // protocol: 'https', + hostname: process.env.NEXT_IMAGE_DOMAIN, + // port: '', + // pathname: '/sites/default/files/**', + }, + ], }, } diff --git a/starters/graphql-starter/package.json b/starters/graphql-starter/package.json index 15db67c2..a8d0986e 100644 --- a/starters/graphql-starter/package.json +++ b/starters/graphql-starter/package.json @@ -8,25 +8,27 @@ "build": "next build", "start": "next start", "preview": "next build && next start", - "lint": "next lint" + "lint": "next lint", + "format": "prettier --write .", + "format:check": "prettier --check ." }, "dependencies": { - "@tailwindcss/typography": "^0.5.8", - "next": "^13 || ^14", + "next": "^14", "next-drupal": "^1.6.0", "react": "^18.2.0", - "react-dom": "^18.2.0", - "sharp": "^0.31.2" + "react-dom": "^18.2.0" }, "devDependencies": { - "@types/node": "^18.11.10", - "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", - "autoprefixer": "^10.4.13", - "eslint": "^8.28.0", - "eslint-config-next": "^13.0.6", - "postcss": "^8.4.19", - "tailwindcss": "^3.2.4", - "typescript": "^5.2.2" + "@tailwindcss/typography": "^0.5.10", + "@types/node": "^20.10.0", + "@types/react": "^18.2.39", + "@types/react-dom": "^18.2.17", + "autoprefixer": "^10.4.16", + "eslint": "^8.54.0", + "eslint-config-next": "^14.0.3", + "postcss": "^8.4.31", + "prettier": "^3.1.0", + "tailwindcss": "^3.3.5", + "typescript": "^5.3.2" } } diff --git a/starters/graphql-starter/pages/[...slug].tsx b/starters/graphql-starter/pages/[...slug].tsx index 7daa2a3e..80a20f16 100644 --- a/starters/graphql-starter/pages/[...slug].tsx +++ b/starters/graphql-starter/pages/[...slug].tsx @@ -1,34 +1,18 @@ -import { GetStaticPathsResult, GetStaticPropsResult } from "next" import Head from "next/head" +import { Article } from "@/components/drupal/Article" +import { BasicPage } from "@/components/drupal/BasicPage" +import { Layout } from "@/components/Layout" +import { drupal, query } from "@/lib/drupal" +import type { + GetStaticPaths, + GetStaticProps, + InferGetStaticPropsType, +} from "next" +import type { NodeArticle, NodePage, NodesPath } from "@/types" -import { Article, NodesPath, Page } from "types" -import { drupal, query } from "lib/drupal" -import { NodeArticle } from "components/node--article" -import { NodeBasicPage } from "components/node--basic-page" -import { Layout } from "components/layout" - -interface NodePageProps { - resource: Article | Page -} - -export default function NodePage({ resource }: NodePageProps) { - if (!resource) return null - - return ( - - - {resource.title} - - - {resource.__typename === "NodePage" && } - {resource.__typename === "NodeArticle" && } - - ) -} - -export async function getStaticPaths(context): Promise { +export const getStaticPaths = (async (context) => { // Fetch the paths for the first 50 articles and pages. - // We'll fallback to on-demand generation for the rest. + // We'll fall back to on-demand generation for the rest. const data = await query<{ nodeArticles: NodesPath nodePages: NodesPath @@ -49,20 +33,19 @@ export async function getStaticPaths(context): Promise { // Build static paths. const paths = drupal.buildStaticPathsParamsFromPaths( - [...data?.nodeArticles?.nodes, ...data?.nodePages?.nodes].map( - ({ path }) => path - ) + [ + ...(data?.nodeArticles?.nodes as []), + ...(data?.nodePages?.nodes as []), + ].map(({ path }) => path) ) return { paths, fallback: "blocking", } -} +}) satisfies GetStaticPaths -export async function getStaticProps( - context -): Promise> { +export const getStaticProps = (async (context) => { if (!context?.params?.slug) { return { notFound: true, @@ -70,7 +53,7 @@ export async function getStaticProps( } const data = await query<{ - nodeByPath: Article + nodeByPath: NodeArticle | NodePage }>({ query: `query ($path: String!){ nodeByPath(path: $path) { @@ -124,4 +107,27 @@ export async function getStaticProps( resource, }, } +}) satisfies GetStaticProps<{ + resource: NodeArticle | NodePage +}> + +export default function Page({ + resource, +}: InferGetStaticPropsType) { + if (!resource) return null + + return ( + + + {resource.title} + + + {resource.__typename === "NodePage" && } + {resource.__typename === "NodeArticle" &&
} + + ) } diff --git a/starters/graphql-starter/pages/_app.tsx b/starters/graphql-starter/pages/_app.tsx index 1c9392b0..70739e9b 100644 --- a/starters/graphql-starter/pages/_app.tsx +++ b/starters/graphql-starter/pages/_app.tsx @@ -1,6 +1,5 @@ -import { AppProps } from "next/app" - -import "styles/globals.css" +import "@/styles/globals.css" +import type { AppProps } from "next/app" export default function App({ Component, pageProps }: AppProps) { return diff --git a/starters/graphql-starter/pages/_document.tsx b/starters/graphql-starter/pages/_document.tsx new file mode 100644 index 00000000..097cb7ff --- /dev/null +++ b/starters/graphql-starter/pages/_document.tsx @@ -0,0 +1,13 @@ +import { Html, Head, Main, NextScript } from "next/document" + +export default function Document() { + return ( + + + +
+ + + + ) +} diff --git a/starters/graphql-starter/pages/api/exit-preview.ts b/starters/graphql-starter/pages/api/exit-preview.ts index cf3ba903..a8cf12e8 100644 --- a/starters/graphql-starter/pages/api/exit-preview.ts +++ b/starters/graphql-starter/pages/api/exit-preview.ts @@ -1,6 +1,9 @@ -import { NextApiResponse } from "next" +import type { NextApiRequest, NextApiResponse } from "next" -export default async function exit(_, response: NextApiResponse) { +export default async function exit( + _: NextApiRequest, + response: NextApiResponse +) { response.clearPreviewData() response.writeHead(307, { Location: "/" }) response.end() diff --git a/starters/graphql-starter/pages/api/preview.ts b/starters/graphql-starter/pages/api/preview.ts index 9581ed10..7660eb64 100644 --- a/starters/graphql-starter/pages/api/preview.ts +++ b/starters/graphql-starter/pages/api/preview.ts @@ -1,10 +1,9 @@ -import { NextApiRequest, NextApiResponse } from "next" - -import { drupal } from "lib/drupal" +import { drupal } from "@/lib/drupal" +import type { NextApiRequest, NextApiResponse } from "next" export default async function handler( request: NextApiRequest, response: NextApiResponse ) { - return await drupal.preview(request, response) + await drupal.preview(request, response) } diff --git a/starters/graphql-starter/pages/api/revalidate.ts b/starters/graphql-starter/pages/api/revalidate.ts index 38dea1c6..cf90a0d4 100644 --- a/starters/graphql-starter/pages/api/revalidate.ts +++ b/starters/graphql-starter/pages/api/revalidate.ts @@ -1,4 +1,4 @@ -import { NextApiRequest, NextApiResponse } from "next" +import type { NextApiRequest, NextApiResponse } from "next" export default async function handler( request: NextApiRequest, @@ -23,7 +23,7 @@ export default async function handler( return response.json({}) } catch (error) { return response.status(404).json({ - message: error.message, + message: (error as Error).message, }) } } diff --git a/starters/graphql-starter/pages/index.tsx b/starters/graphql-starter/pages/index.tsx index bba9533f..c5c5bca6 100644 --- a/starters/graphql-starter/pages/index.tsx +++ b/starters/graphql-starter/pages/index.tsx @@ -1,49 +1,15 @@ import Head from "next/head" -import { GetStaticPropsResult } from "next" +import { ArticleTeaser } from "@/components/drupal/ArticleTeaser" +import { Layout } from "@/components/Layout" +import { query } from "@/lib/drupal" +import type { InferGetStaticPropsType, GetStaticProps } from "next" +import type { NodeArticle } from "@/types" -import { query } from "lib/drupal" -import { Layout } from "components/layout" -import { NodeArticleTeaser } from "components/node--article--teaser" -import { Article } from "types" - -interface IndexPageProps { - nodes: Article[] -} - -export default function IndexPage({ nodes }: IndexPageProps) { - return ( - - - Next.js for Drupal - - -
-

Latest Articles.

- {nodes?.length ? ( - nodes.map((node) => ( -
- -
-
- )) - ) : ( -

No nodes found

- )} -
-
- ) -} - -export async function getStaticProps( - context -): Promise> { +export const getStaticProps = (async (context) => { // Fetch the first 10 articles. const data = await query<{ nodeArticles: { - nodes: Article[] + nodes: NodeArticle[] } }>({ query: ` @@ -76,4 +42,34 @@ export async function getStaticProps( nodes: data?.nodeArticles?.nodes ?? [], }, } +}) satisfies GetStaticProps<{ + nodes: NodeArticle[] +}> + +export default function Home({ + nodes, +}: InferGetStaticPropsType) { + return ( + + + Next.js for Drupal + + +

Latest Articles.

+ {nodes?.length ? ( + nodes.map((node) => ( +
+ +
+
+ )) + ) : ( +

No nodes found

+ )} +
+ ) } diff --git a/starters/graphql-starter/tailwind.config.js b/starters/graphql-starter/tailwind.config.js deleted file mode 100644 index 81060f34..00000000 --- a/starters/graphql-starter/tailwind.config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - mode: "jit", - content: [ - "./pages/**/*.{js,ts,jsx,tsx}", - "./components/**/*.{js,ts,jsx,tsx}", - ], - theme: { - extend: {}, - }, - variants: { - extend: {}, - }, - plugins: [require("@tailwindcss/typography")], -} diff --git a/starters/graphql-starter/tailwind.config.ts b/starters/graphql-starter/tailwind.config.ts new file mode 100644 index 00000000..c7f5c8a1 --- /dev/null +++ b/starters/graphql-starter/tailwind.config.ts @@ -0,0 +1,18 @@ +import type { Config } from "tailwindcss" + +const config: Config = { + content: [ + "./pages/**/*.{js,ts,jsx,tsx,mdx}", + "./components/**/*.{js,ts,jsx,tsx,mdx}", + "./app/**/*.{js,ts,jsx,tsx,mdx}", + ], + theme: { + extend: {}, + }, + variants: { + extend: {}, + }, + plugins: [require("@tailwindcss/typography")], +} + +export default config diff --git a/starters/graphql-starter/tsconfig.json b/starters/graphql-starter/tsconfig.json index f2303bdd..ad54f56d 100644 --- a/starters/graphql-starter/tsconfig.json +++ b/starters/graphql-starter/tsconfig.json @@ -4,17 +4,19 @@ "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, - "strict": false, + "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "baseUrl": "./", - "incremental": true + "incremental": true, + "paths": { + "@/*": ["./*"] + } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] diff --git a/starters/graphql-starter/types/index.d.ts b/starters/graphql-starter/types/index.d.ts index e2a7cca7..fc52cc6e 100644 --- a/starters/graphql-starter/types/index.d.ts +++ b/starters/graphql-starter/types/index.d.ts @@ -18,7 +18,7 @@ export type Author = { displayName: string } -export type Page = { +export type NodePage = { __typename: "NodePage" id: string status: boolean @@ -29,7 +29,7 @@ export type Page = { } } -export type Article = { +export type NodeArticle = { __typename: "NodeArticle" id: string status: boolean