paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
687 stars 55 forks source link

Fresh nextjs insallation fail #192

Closed cesarve77 closed 3 years ago

cesarve77 commented 3 years ago

I follow the steps but I got this error


$ yarn generate
yarn run v1.22.10
$ yarn generate:prisma && yarn generate:nexus && yarn codegen
$ prisma generate
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (2.17.0) to ./node_modules/@prisma/client in 125ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

$ ts-node --transpile-only -P nexus.tsconfig.json src/Api/nexusSchema
$ graphql-codegen --config codegen.yml
  ✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate src/generated/index.ts
      ✖ Load GraphQL schemas
        → Failed to load schema
        Load GraphQL documents
        Generate

 Found 1 error

  ✖ src/generated/index.ts
    Failed to load schema from src/schema.graphql:

      Unable to find any GraphQL type definitions for the following pointers:

          - src/schema.graphql

        Error: 
      Unable to find any GraphQL type definitions for the following pointers:

          - src/schema.graphql

    at prepareResult (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:591:15)
    at loadTypedefs (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:556:12)
    at async Object.loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:641:21)
    at async loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:452:24)
    at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
    at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.
    Error: Failed to load schema
        at loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:460:15)
        at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
        at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)
    Error: Failed to load schema
        at loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:460:15)
        at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
        at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)

Something went wrong
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
AhmedElywa commented 3 years ago

@cesarve77 I think you changed the codegen.yml file code.

here is the default content

overwrite: true
schema: 'src/generated/schema.graphql'
documents: 'src/graphql/**/*.graphql'
generates:
  src/generated/index.ts:
    plugins:
      - 'typescript'
      - 'typescript-operations'
      - 'typescript-react-apollo'
    config:
      withHooks: true
      withComponent: false
      withHOC: false
      withMutationFn: false
      maybeValue: T | undefined
      reactApolloVersion: 3

your error means you changed the second line from schema: 'src/generated/schema.graphql' to schema: 'src/schema.graphql'

cesarve77 commented 3 years ago

It is a fresh instalation, I do it again and I got the same error:

cmp:pal cesarramos$ pal c

.______      ___       __             __       _______.
|   _  \    /   \     |  |           |  |     /       |
|  |_)  |  /  ^  \    |  |           |  |    |   (----`
|   ___/  /  /_\  \   |  |     .--.  |  |     \   \
|  |     /  _____  \  |  `----.|  `--'  | .----)   |
| _|    /__/     \__\ |_______| \______/  |_______/

✔ Please select your start example · full-stack-nextjs
✔ please enter your project name · next
✔ please enter your project description · 
✔ please enter your project author · 
✔ please enter your project repository · 
✔ please select your package manager · yarn
✔ Skip package installation · no

Hang tight while we set up your great new app!

create .eslintignore
create .eslintrc.js
create .gitignore
create .prettierignore
create .prettierrc.js
create README.md
create adminSettings.json
create codegen.yml
create next-env.d.ts
create next.config.js
create nexus.tsconfig.json
create package.json
create pal.js
create .env
create schema.prisma
create favicon.ico
create .prettierrc.js
create client.tsx
create context.ts
create Auth.ts
create index.ts
create nexusSchema.ts
create utils.ts
create Socials.tsx
create index.tsx
create PrismaTable.tsx
create Header.tsx
create SimpleLayout.ts
create index.tsx
create menuItem.ts
create themes.ts
create Auth.graphql
create 404.tsx
create _app.tsx
create login.tsx
create register.tsx
create request-password.tsx
create reset-password.tsx
create index.tsx
create graphql.ts
create index.tsx
create styled.d.ts
create tsconfig.json

✔ Retrieving the freshest of dependencies
✔ Resolving packages
✔ Fetching packages
✔ Linking dependencies
✔ Building fresh packages
✔ Formatting your code

Your new great app is ready! Next steps:

Go inside your project folder

> cd next

Please open README.md file and go with steps

cmp:pal cesarramos$ ls
gqlmod  next    pal sdl
cmp:pal cesarramos$ cd next
cmp:next cesarramos$ yarn create-migration
yarn run v1.22.10
$ prisma migrate dev --preview-feature
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"

SQLite database dev.db created at file:./dev.db

✔ Name of migration … init
The following migration(s) have been created and applied from new schema changes:

migrations/
  └─ 20210223020229_init/
    └─ migration.sql

✔ Generated Prisma Client (2.17.0) to ./node_modules/@prisma/client in 347ms

Everything is now in sync.
✨  Done in 14.07s.
cmp:next cesarramos$ yarn migrate-database
yarn run v1.22.10
$ prisma db push --preview-feature
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"

The database is already in sync with the Prisma schema.

✨  Done in 1.42s.
cmp:next cesarramos$ pal g
Prisma Schema loaded from prisma/schema.prisma
✔ Generating your files
cmp:next cesarramos$ yarn generate
yarn run v1.22.10
$ yarn generate:prisma && yarn generate:nexus && yarn codegen
$ prisma generate
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (2.17.0) to ./node_modules/@prisma/client in 98ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient()

$ ts-node --transpile-only -P nexus.tsconfig.json src/Api/nexusSchema
$ graphql-codegen --config codegen.yml
  ✔ Parse configuration
  ❯ Generate outputs
    ❯ Generate src/generated/index.ts
      ✖ Load GraphQL schemas
        → Failed to load schema
        Load GraphQL documents
        Generate

 Found 1 error

  ✖ src/generated/index.ts
    Failed to load schema from src/generated/schema.graphql:

      Unable to find any GraphQL type definitions for the following pointers:

          - src/generated/schema.graphql

        Error: 
      Unable to find any GraphQL type definitions for the following pointers:

          - src/generated/schema.graphql

    at prepareResult (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:591:15)
    at loadTypedefs (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:556:12)
    at async Object.loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-tools/load/index.cjs.js:641:21)
    at async loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:452:24)
    at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
    at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.
    Error: Failed to load schema
        at loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:460:15)
        at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
        at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)
    Error: Failed to load schema
        at loadSchema (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:460:15)
        at async /Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:872:55
        at async Task.task (/Users/cesarramos/Documents/projects/test/pal/next/node_modules/@graphql-codegen/cli/bin.js:725:17)

Something went wrong
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
cmp:next cesarramos$ 
cesarve77 commented 3 years ago

Basicly the problem is that this src/generated/schema.graphql does not exists in the fresh installation

you need src/generated/schema.graphql to run yarn dev, and yourneed yarn dev to create src/generated/schema.graphql

How I fixed: I removed the dependencies to generated folder from _app, run yarn dev. and everything is working now.

but it need to be fixed in order to pal c works properly.

AhmedElywa commented 3 years ago

It's working good in my laptop Can you tell me what your nodejs version is? And your operation system?

cesarve77 commented 3 years ago

I tried node v14.3.0 node v12.16.1 MAC OS 11.2.1

AhmedElywa commented 3 years ago

Not found any issues after testing