sails-graphql icon indicating copy to clipboard operation
sails-graphql copied to clipboard

generateSchema(sails.models)

Open tlimpanont opened this issue 7 years ago • 8 comments

using

import { generateSchema } from 'sails-graphql';
 generateSchema(sails.models);

causes

TypeError: Cannot read property 'charAt' of undefined

Client.js

module.exports = {

  attributes: {
    id: {
      type: 'string',
      primaryKey: true,
      required: true
    },
    firstname: {
      type: 'string'
    },
    lastname: {
      type: 'string'
    },
    therapists: {
      unique: true,
      collection: "therapist",
      via: "clients"
    }
  }
};


Therapist.js

module.exports = {

  attributes: {
    id: {
      type: 'string',
      primaryKey: true,
      required: true
    },
    firstname: {
      type: 'string'
    },
    lastname: {
      type: 'string'
    },
    clients: {
      unique: true,
      collection: "client",
      via: "therapists"
    }
  }
};


tlimpanont avatar Mar 24 '17 15:03 tlimpanont

+1

benediktdertinger avatar Apr 27 '17 09:04 benediktdertinger

+1

scottrhoyt avatar May 10 '17 05:05 scottrhoyt

The root of this problem appears to be when types, queries, and mutations are attempted to be created for waterline-generated join models. You can get around this by filtering the models with hasSchema == true. However, this just opens up the door for many other issues. Overall, the library is not ready for use.

scottrhoyt avatar May 10 '17 07:05 scottrhoyt

+1

tonespy avatar May 14 '17 04:05 tonespy

+1

AndrewHossam avatar Sep 14 '17 12:09 AndrewHossam

Any updates on this?

jhnferraris avatar Dec 22 '17 16:12 jhnferraris

I tried @scottrhoyt solution for model that has schema. But still the same error appears. Any ideas guys?

AmaarHassan avatar Apr 03 '19 12:04 AmaarHassan

I'm sorry for not looking at this project for a very long time. I just created it for fun a few years ago and didn't expect that it can be useful for someone else. Honestly, I forgot that it even exists :) I'll look into this issue in the near future.

zhukmj avatar Aug 07 '19 10:08 zhukmj