question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Regression] type-graphql datetime cannot be parsed

See original GitHub issue

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 upgraded @nestjs/graphql from 6.0.5 to 6.2.1 today and found this regression.

When I did the mutation postPoem like

mutation {
  postPoem(newPoem: {
    "title": "AA",
    "content": "BB",
    "isPublic": true
  }) {
    id
    createdAt
  }
}

The error GraphQL Cannot return null for non-nullable field 'createdAt' occurred. When I did not request the createdAt property, it worked well.

Below is the complete generated schema

# -----------------------------------------------
# !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!!
# !!!   DO NOT MODIFY THIS FILE BY YOURSELF   !!!
# -----------------------------------------------

input CreatePoemInput {
  title: String!
  content: String!
  isPublic: Boolean = false
}

input CreateUserInput {
  name: String!
  email: String!
  password: String!
}

"""
The javascript `Date` as string. Type represents date and time as the ISO Date string.
"""
scalar DateTime

type JsonWebToken {
  token: String!
  expiresAt: Float!
}

type Mutation {
  signUp(newUser: CreateUserInput!): Session!
  logIn(password: String!, email: String!): Session!
  postPoem(newPoem: CreatePoemInput!): Poem!
  deletePoem(id: String!): String!
  updatePoem(newPoem: CreatePoemInput!, id: String!): Poem!
}

type Poem {
  id: ID!
  title: String!
  content: String!
  isPublic: Boolean
  createdAt: DateTime!
  updatedAt: DateTime!
  author: User!
}

type Query {
  user(id: String!): User!
  poem(id: String!): Poem!
  allPublicPoems(take: Float, skip: Float): [Poem!]!
  myPoems(take: Float, skip: Float): [Poem!]!
}

type Session {
  jwt: JsonWebToken!
  user: User!
}

type User {
  id: ID!
  name: String!
  email: String!
  poems: [Poem!]!
}

Expected behavior

createdAt should be parsed correctly.

Minimal reproduction of the problem with instructions

My Repo A PostgreSQL should be set up in src/database/database.provider.ts before running the program.

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.2.4

 
For Tooling issues:
- Node version: 10.15.3  
- Platform: Mac 

Others:

I am sure this is directly related to @nestjs/graphql. Actually I upgraded all nest.js libraries. The error occurred. I then downgraded only @nestjs/graphql, and the error disappeared.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lucifer1004commented, Jun 6, 2019

I have solved this issue in this commit

Apparently, I should have used new Date() directly instead of new Date().toISOString(), but it worked well in @nestjs/graphql <= 6.0.5.

So this issue can be closed now.

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scalars - TypeGraphQL
TypeGraphQL provides aliases for 3 basic scalars: Int --> GraphQLInt;; Float --> GraphQLFloat;; ID --> GraphQLID;. This shorthand allows you to save keystrokes ......
Read more >
graphql-ruby, Date or Datetime type - Stack Overflow
Keep in mind that the DateTimeType you pasted is in the module "Types". ... Boolean, ID) defined as method which means you cannot...
Read more >
Custom scalars - Apollo GraphQL Docs
The following GraphQLScalarType object defines interactions for a custom scalar that represents a date (this is one of the most commonly implemented custom ......
Read more >
DQL's GraphQL Variables (not GraphQL itself) variables does ...
What you wanted to do Use a datetime graphql variable in DQL: query … ... parsing time "1483228800" as "2006-01-02": cannot parse "228800" ......
Read more >
GraphQL specification
Fragments cannot be specified on any input value (scalar, enumeration, or input ... GraphQL query execution may choose not to parse TypeSystemDefinition.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found