leebenson / graphql-with-sequelize Goto Github PK
View Code? Open in Web Editor NEWGraphQL working with Sequelize.js
GraphQL working with Sequelize.js
Hi,
I would like to hear your thoughts on this
Hey!
I've just started playing around with this. It's a great introduction!
Here we're fetching all person
entries and let the graphql-relay lib do the pagination. How would you go about this if you want to make sure you could do pagination without fetching all the entries?
Hi there @leebenson ! I have a simple question. How would one split the schema into maybe separate folders or at least files to make it easier to mantain? Thanks in advance!
Lee,
This is probably a newbie goof, but I had to replace your inline object reference to create a post with the person's firstName (in db.js)...
// title: 'Sample title by ${person.firstName}',
title: 'Sample title by ' + person.firstName,
I am using node 6 rather than node 5 - Do you know if I have to add another dependency to get this object reference functionality?
Thanks
Getting below error with MySQL
connection:
{
"errors": [
{
"message": "Cannot read property 'person' of undefined",
"locations": [
{
"line": 29,
"column": 3
}
],
"path": [
"people"
]
}
],
"data": {
"people": null
}
}
hello I found this error when I run
./node_modules/.bin/babel-node server.js
here all the trace of information:
/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/node_modules/babel-runtime/helpers/class-call-check.js:5 throw new TypeError("Cannot call a class as a function"); TypeError: Cannot call a class as a function at exports.default (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/node_modules/babel-runtime/helpers/class-call-check.js:5:11) at GraphQLNonNull (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/definition.js:759:5) at fields (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/schema.js:137:19) at resolveMaybeThunk (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/definition.js:265:47) at defineFieldMap (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/definition.js:284:18) at GraphQLObjectType.getFields (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/definition.js:245:46) at /Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/schema.js:174:29 at typeMapReducer (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/schema.js:186:9) at Array.reduce (native) at new GraphQLSchema (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/graphql/type/schema.js:81:120) at Object.<anonymous> (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/schema.js:159:16) at Module._compile (module.js:570:32) at loader (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/babel-register/lib/node.js:144:5) at Object.require.extensions.(anonymous function) [as .js] (/Users/lrodriguez/graphql-sequelize-test/graphql-with-sequelize/node_modules/babel-register/lib/node.js:154:7) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)
Hello, I'm having trouble getting this code to work
const articleType = new GraphQLObjectType({
name: 'Article',
fields: {
id: {
type: GraphQLInt
},
name: {
type: GraphQLString
},
description: {
type: GraphQLString
},
createdBy: {
type: userType,
resolve(article) {
return article.findUser();
}
}
}
});
const userType = new GraphQLObjectType({
name: 'User',
fields: {
id: {
type: GraphQLInt
},
name: {
type: GraphQLString
},
lastName: {
type: GraphQLString
},
email: {
type: GraphQLString
},
createdAt: {
type: GraphQLString
},
articles: {
type: new GraphQLList(articleType),
resolve(user) {
return user.getArticles();
}
}
}
});
in articleType
I'm trying to use userType
but when I run the server it errrors out with Article.createdBy field type must be Output Type but got: undefined.
How can I fix this :l
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.