We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module.exports = (sequelize, DataTypes) => { let Speaker = sequelize.define('Speaker', { // eslint-disable-line name: { type: DataTypes.STRING(128), allowNull: false }, // eslint-disable-line description: DataTypes.STRING, position: DataTypes.STRING(128), // eslint-disable-line company: DataTypes.STRING(128), // eslint-disable-line }, { classMethods: { associate: (models) => { Speaker.Presentations = Speaker.hasMany(models.Presentation, { as: 'presentations' }); }, }, }); return Speaker; };
module.exports = (sequelize, DataTypes) => { const Presentation = sequelize.define('Presentation', { title: { type: DataTypes.STRING(128), allowNull: false }, // eslint-disable-line description: DataTypes.STRING, }, { classMethods: { associate: (models) => { Presentation.Speaker = Presentation.belongsTo(models.Speaker, { as: 'speaker', foreignKey: 'speakerId', onDelete: 'CASCADE', }); }, }, }); return Presentation; };
'use strict'; const fs = require('fs'); const path = require('path'); const Sequelize = require('sequelize'); const sequelize = new Sequelize('xxxxx', 'xxxxx', 'xxxxx', { host: 'localhost', dialect: 'mariadb', }); let db = {}; fs .readdirSync(__dirname) .filter((file) => (file.indexOf('.') !== 0) && (file !== 'index.js')) .forEach((file) => { const model = sequelize.import(path.join(__dirname, file)); db[model.name] = model; }); Object.keys(db).forEach((modelName) => { if ('associate' in db[modelName]) { db[modelName].associate(db); } }); db.sequelize = sequelize; db.Sequelize = Sequelize; module.exports = db;
import { resolver } from 'graphql-sequelize'; import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLInt, } from 'graphql'; import { Presentation } from '../models'; import speakerType from './speakerType'; const presentationType = new GraphQLObjectType({ name: 'Presentation', description: 'A Presentation', fields: { id: { type: new GraphQLNonNull(GraphQLInt), description: 'Presentation Id', }, title: { type: new GraphQLNonNull(GraphQLString), description: 'Presentation Title', }, description: { type: GraphQLString, description: 'Presentation Description', }, speaker: { type: speakerType, resolve: resolver(Presentation.Speaker), }, }, }); export default presentationType;
error:
Error: Presentation.speaker field type must be Output Type but got: undefined.
Can't seem to get references to work
The text was updated successfully, but these errors were encountered:
The resolver is not your issue, the type for speaker is undefined, try logging speakerType
type
speakerType
Sorry, something went wrong.
think I found it ... just assumed that was ok:
https://gist.github.com/xicombd/77406c29ddf37fe46c3c
Closed. Thank you Mick, fyi for anyone else who might encounter this.
No branches or pull requests
error:
Can't seem to get references to work
The text was updated successfully, but these errors were encountered: