nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.46k stars 396 forks source link

Type "Date" was defined more than once. #64

Closed quen2404 closed 6 years ago

quen2404 commented 6 years ago

I'm submitting a...


[x] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I defined a scalar of type Date in my graphql schema.

scalar Date
#...

But i have this error message at startup.

(node:8372) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Type "Date" was defined more than once.

If i try to remove my scalar declaration, my nestjs application starts but gives me this message in the console:

Type "ICat" is missing a "resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
Type "Character" is missing a "resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
Type "SearchResult" is missing a "resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.

This is weird because i have none of theses types defined in my schema. It looks like an example schema.

Expected behavior

I have this behavior since i upgrade @nestjs/graphl from version 5.2.0 to 5.2.1.

Environment


Nest graphql: 5.2.1


For Tooling issues:
- Node version: 8.9.1  
- Platform: Windows            
cschroeter commented 6 years ago

With the latest release @kamilmysliwiec add a test-schema.graphql to the graphql module.

type Query {
  getCats: [Cat]
  cat(id: ID!): Cat
}

type Mutation {
  createCat(cat: CreateCatInput): Cat
}

input CreateCatInput {
  name: Date
}

scalar Date

type Subscription {
  catCreated: Cat
}

type Cat implements ICat {
  id: Int
  name: String
  age: Int
}

interface ICat {
  id: Int
  name: String
}

interface Character {
  id: ID!
  name: String!
}

enum Episode {
  NEWHOPE
  EMPIRE
  JEDI
}

type Human implements Character {
  id: ID!
  name: String!
  totalCredits: Int
}

type Droid implements Character {
  id: ID!
  name: String!
  primaryFunction: String
}

union SearchResult = Droid | Human

To get rid off this warnings you could specify the typePaths to

GraphQLModule.forRoot({
      typePaths: ['./src/**/*.graphql']
})
kamilmysliwiec commented 6 years ago

Unbelievable! Just pushed 5.2.2 fix. Thanks for reporting :)

quen2404 commented 6 years ago

Ahaha no problem @kamilmysliwiec ! Thank you for your reactivity and for this amazing project 💯

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.