prisma-labs / graphqlgen

⚙️ Generate type-safe resolvers based upon your GraphQL Schema
MIT License
818 stars 54 forks source link

create-graphqlgen typescript-yoga template does not start #396

Closed nunovieira closed 5 years ago

nunovieira commented 5 years ago

Description

The create-graphqlgen typescript-yoga template does not start.

Steps to reproduce

npm init graphqlgen my-app4 --template typescript-yoga
(cd my-app4 && npm start)

Expected results

Application running.

Actual results

$ (cd my-app4 && npm start)

> graphqlgen-template-yoga@0.0.0 start /Users/nuno/Developer/my-app4
> nodemon -x ts-node --no-cache src/index.ts

[nodemon] 1.18.9
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `ts-node --no-cache src/index.ts`

/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/resolvers/Mutation.ts(4,3): error TS2322: Type '(parent: undefined, { name }: ArgsCreateUser, ctx: Context) => { id: string; name: string | null | undefined; postIDs: never[]; }' is not assignable to type '(parent: undefined, args: ArgsCreateUser, ctx: Context, info: GraphQLResolveInfo) => User | Promise<User>'.
  Type '{ id: string; name: string | null | undefined; postIDs: never[]; }' is not assignable to type 'User | Promise<User>'.
    Type '{ id: string; name: string | null | undefined; postIDs: never[]; }' is not assignable to type 'User'.
      Types of property 'name' are incompatible.
        Type 'string | null | undefined' is not assignable to type 'string | null'.
          Type 'undefined' is not assignable to type 'string | null'.
src/resolvers/Mutation.ts(7,25): error TS2345: Argument of type '{ id: string; name: string | null | undefined; postIDs: never[]; }' is not assignable to parameter of type 'User'.

    at createTSError (/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:531:13)
    at Module.m._compile (/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/nuno/Developer/my-app4/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
[nodemon] app crashed - waiting for file changes before starting...

Versions

nunovieira commented 5 years ago

Looks like the problem is here. In createUser(name: String): User!, should name be required? Looking at the flow-yoga template, I'm assuming yes.

jasonkuhrt commented 5 years ago

Closed by #397 Thanks @nunovieira!