Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

Cannot convert json schema type "timestamp" into GraphQL type #33

Closed alexisohayon closed 6 years ago

alexisohayon commented 6 years ago

Hi! I didn't find a way to make this work, dont know what to do..?

Thanks ;)

koskimas commented 6 years ago

timestamp is not a valid json schema type. You shouldn't use that.

alexisohayon commented 6 years ago

Good to know..! What do you use as type when it's a timestamp in the database? just date?

koskimas commented 6 years ago

Date isn't a type either. You should probably read the this. JSON schema only allows json types string, boolean, number, null, object and array. For other types you need to use format keyword.

alexisohayon commented 6 years ago

Thanks, still learning :) It helps a lot <3

CoveMB commented 4 years ago

Hello! I am facing the same problem, One of my models has a date time value (expiration) as following, so I triwed to call it "format as recommanded but I get

cannot convert json schema type "format" into GraphQL type

static get jsonSchema() {

    return {
      type    : 'object',
      required: [ 'token' ],

      properties: {
        id    : { type: 'integer' },
        userId: { type: 'integer' },
        device: {
          type: 'string', minLength: 1, maxLength: 255
        },
        expiration: { type: 'format' },
        token     : {
          type: 'string', minLength: 1, maxLength: 255
        },
      }
    };

  }

Any ideas @koskimas , maybe I am doing something wrong? Thanks for your help.

It seems that date and date-time are new type in the json schema ? https://json-schema.org/understanding-json-schema/reference/string.html