Comments (6)
Hi!
Have you connected to the mongodb?https://github.com/RisingStack/graffiti/blob/master/example/schema/index.js#L6
from graffiti-mongoose.
Here are the relevant parts of my server.js -- I am connecting to mongo and express graphql was working before on my normal schema. I just tested my normal schema as well with graffiti and its not working, so its possible this issue should be posted in that repo.
'use strict'
import express from 'express'
....
var User = require('./models/user')
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser')
var cors = cors = require('cors')
var passport = require('passport')
var session = require('cookie-session')
const app = global.app = express()
const mongo = (global.process.env.NODE_ENV == 'development') ? 'mongodb://localhost/graph' : global.process.env.MONGOLAB_URI
const port = (global.process.env.NODE_ENV == 'development') ? 8080 : global.process.env.PORT
mongoose.connect(mongo);
app.set('port', port)
app.set('view engine', 'jade')
app.set('views', __dirname + '/views')
app.use(cookieParser())
app.use(session({keys: ['secretkey1']}))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cors())
app.use(passport.initialize())
app.use(passport.session())
initialize_passport(passport)
console.log(path.join(__dirname, '../deploy'))
app.use(express.static(path.join(__dirname, '../deploy')))
app.use(set_locals)
app.use('/', router)
//THIS WAS WORKING BEFORE
// app.use('/graphql', graphqlHTTP(request => ({
// schema: schema,
// graphiql: true,
// rootValue: { request: request},
// })))
app.use(graffiti.express({
schema: getSchema([User])
}))
from graffiti-mongoose.
Are you sure these 3 lines are necessary?
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cors())
I am only on my phone, just guessing.
from graffiti-mongoose.
@tothandras no worries! Any help is appreciated :).
I know CORS it necessary for some other things I'm doing unrelated to graphql, but I haven't factored it out into a mounted sub-app yet. Let me see if removing them will change it.
from graffiti-mongoose.
hah, that was quick :).
The body parser was holding everything up. Thanks for the help!
from graffiti-mongoose.
I'm glad I was able to help! :)
from graffiti-mongoose.
Related Issues (20)
- Implicit dependency on babel-polyfill HOT 9
- Cannot set currently-valued fields to null in update mutation HOT 2
- How to make a custom field: id? HOT 10
- "TypeError: Cannot read property 'forEach' of undefined" when embedded object field is a reference HOT 6
- Custom query thunk - accepts only InputObject types HOT 3
- Question on customQueries HOT 7
- Example project doesnt work with [email protected] and [email protected] HOT 1
- Async hook support HOT 2
- How to use Express Middleware for Authentication/Authorization. HOT 4
- Get specific field validation error?
- How to mutate nested Schema? HOT 3
- What is different between id and _id HOT 1
- UNMET PEER DEPENDENCY HOT 1
- Maintainer Volunteer Thread HOT 1
- Mongoose ObjectId and GraphQL id is not the same. How to link them? HOT 5
- It is possible to add some description to schema and to be reflected in the docs?
- Does graffiti-mongoose works with react-apollo ? HOT 2
- Custom mutations?
- Custom queries/mutations HOT 1
- setTypeFields bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graffiti-mongoose.