Giter Club home page Giter Club logo

waterline-to-graphql's People

Contributors

agenthunt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

waterline-to-graphql's Issues

Need some help (Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory.)

I am trying to use the module but, the result is:

{
"errors": [
{
"message": "Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory."
}
]
}

Query:
{master_tenaga_budaya{nama,no_identitas}}

Log of Schema:

GraphQLSchema {
  _queryType: Query,
  _mutationType: Mutation,
  _subscriptionType: undefined,
  _directives: 
   [ GraphQLDirective {
       name: 'include',
       description: 'Directs the executor to include this field or fragment only when the `if` argument is true.',
       locations: [Array],
       astNode: undefined,
       args: [Array] },
     GraphQLDirective {
       name: 'skip',
       description: 'Directs the executor to skip this field or fragment when the `if` argument is true.',
       locations: [Array],
       astNode: undefined,
       args: [Array] },
     GraphQLDirective {
       name: 'deprecated',
       description: 'Marks an element of a GraphQL schema as no longer supported.',
       locations: [Array],
       astNode: undefined,
       args: [Array] } ],
  astNode: null,
  _typeMap: 
   { Query: Query,
     String: String,
     Node: Node,
     master_lembaga: master_lembaga,
     Int: Int,
     Boolean: Boolean,
     master_tenaga_budaya: master_tenaga_budaya,
     Mutation: Mutation,
     __Schema: __Schema,
     __Type: __Type,
     __TypeKind: __TypeKind,
     __Field: __Field,
     __InputValue: __InputValue,
     __EnumValue: __EnumValue,
     __Directive: __Directive,
     __DirectiveLocation: __DirectiveLocation },
  _implementations: { Node: [ master_lembaga, master_tenaga_budaya ] } }

Model:

module.exports = {
	identity: 'master_tenaga_budaya',
	attributes: {
		doc_id: {type: 'integer', defaultsTo:null},
		nutb: {type: 'string', defaultsTo:null},
		warganegara_indonesia: {type: 'boolean', required: true, defaultsTo: true},
		no_identitas: {type: 'string', unique: true, required: true},
		nama: {type: 'string', required: true},
		tanggal_lahir: {type: 'date', required: true},
		foto: {type: 'string', defaultsTo:null},
		createdAt: {type: 'integer', required: true},
		updatedAt: {type: 'integer', defaultsTo:null},
		revision: {type: 'integer', defaultsTo:0},
		is_deleted: {type: 'boolean', required: true, defaultsTo: false},
		jenis_identitas: {type: 'string', required: true, defaultsTo:'KTP'},
		jenis_kelamin: {type: 'string', enum:['m','f'], defaultsTo:null}
	}
}

Any idea?

Sails E_VALIDATION Error

I am trying to use the module but, haven't been able to utilize it.

I did the normal Sails Model/Controller configuration. But, anytime I try to use the endpoint, I get an E_VALIDATION Error.

DownloadController.js

module.exports = {

	downloadGraphql: (req, res) => {

		const data = req.body;
		let schema = graphWaterline.getGraphQLSchemaFrom(sails.models);
		graphql.graphql(schema, data.query, null).then(result => {
			console.log(JSON.stringify(result, null, 2));
		}).catch(err => console.log("OfficialError: ", err));
	}
};

Testing With Mocha
DownloadController.test.js

describe("UserController Tests", () => {

	before(done => {
		done();
	})

	describe("#create", () => {

		it("should return 200: Download Created successfully", done => {
	        request(sails.hooks.http.app)
	            .post('/download')
	            .expect(200)
	            .send({"query": `mutation download{createDownload(name:"The Sone", magnetUrl:"ssasasuadiuisudis", totalSize:"200MB", stillInDirectory:true){id, name, magnetUrl, stillInDirectory}}`})
	            .end((err, res) => {
	                /*if (err) console.log("ResponseError: ", err.body);
					console.log("ResponseBody: ", res.body);*/
	                done();
	            });
	    });
	})
})

When I run mocha to test, I added a before validate in my model, and I get this:

ModelLog:  { 
	isCompleted: false,
	stillInDirectory: false,
	isDownloading: false 
}

And this is the full error:

{
  "data": {
    "createDownload": null
  },
  "errors": [
    {
      "message": "[Error (E_VALIDATION) 2 attributes are invalid] Invalid attributes sent to Download:\n • name\n   • Value should be a string (instead of null, which is an object)\n   • \"required\" validation rule failed for input: null\nSpecifically, it threw an error.  Details:\n undefined\n • magnetUrl\n   • Value should be a string (instead of null, which is an object)\n   • \"required\" validation rule failed for input: null\nSpecifically, it threw an error.  Details:\n undefined\n",
      "locations": [
        {
          "line": 1,
          "column": 19
        }
      ],
      "path": [
        "createDownload"
      ]
    }
  ]
}

This is my full model:

module.exports = {

	attributes: {

		name: {
			type: 'string',
			required: true
		},

		magnetUrl: {
			type: 'string',
			required: true,
		},

		totalSize: {
			type: 'string'
		},

		currentlyDownloaded: {
			type: 'string'
		},

		user: {
			model: 'user'
		},

		isCompleted: {
			type: 'boolean',
			defaultsTo: false
		},

		stillInDirectory: {
			type: 'boolean',
			defaultsTo: false
		},

		isDownloading: {
			type: 'boolean',
			defaultsTo: false
		}
	},

	beforeValidate: function(values, next) {
		console.log("ModelLog: ", values);
		next()
	},

    softDelete: function(criteria) {
        return this.update(criteria, {
            isDeleted: true
        });
    }
};

need any help?

Hey @agenthunt, this is Travis from Balderdash, the company behind Sails.js. I'm reaching out to see if you'd like to collaborate on this project, and get some insight on the current state of the project. My email address is in my github profile, I'd love if you could send me a message and we can chat there. Thanks.

cc @yejodido

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.