Coder Social home page Coder Social logo

Comments (6)

tothandras avatar tothandras commented on July 19, 2024

Hi!
Have you connected to the mongodb?https://github.com/RisingStack/graffiti/blob/master/example/schema/index.js#L6

from graffiti-mongoose.

jontonsoup avatar jontonsoup commented on July 19, 2024

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.

tothandras avatar tothandras commented on July 19, 2024

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.

jontonsoup avatar jontonsoup commented on July 19, 2024

@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.

jontonsoup avatar jontonsoup commented on July 19, 2024

hah, that was quick :).

The body parser was holding everything up. Thanks for the help!

from graffiti-mongoose.

tothandras avatar tothandras commented on July 19, 2024

I'm glad I was able to help! :)

from graffiti-mongoose.

Related Issues (20)

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.