3

I’m learning GraphQL so I got a strange issue

I have this code on one file Schema.js:

const graphQL = require('graphql');
const lodash = require('lodash')
const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLID, GraphQLSchema, GraphQLList } = graphQL;

const StatusType = new GraphQLObjectType({
name: 'Status',
fields: () => ({
    id: { type: GraphQLInt },
    statusName: { type: GraphQLString },
    user: {
        type: new GraphQLList(UserType),
        resolve(parentValue, args){
            
        }
    }
})
});

const UserType = new GraphQLObjectType({
name: 'User',
fields: () => ({
    id: { type: GraphQLString },
    username: { type: GraphQLString },
    mail: { type: GraphQLString },
    password: { type: GraphQLString },
    status: { 
        type: StatusType,
        resolve(parentValue, args){
            
        }
    },
})
});

const RouteQuery = new GraphQLObjectType({
name: 'RouteQuery',
user: {
        type: UserType,
        args: { id: { type: GraphQLString } },
        resolve(parentValue, args){
            //return lodash.find(users, { id: args.id })
        }
    },
userSome: {
        type: new GraphQLList(UserType),
        args: { id: { type: GraphQLString } },
        resolve(parentValue, args){
            if (args.id) {
                //return users.filter(user => user.id === args.id);
            }
            //return users;
        }
    },
userAll: {
        type: new GraphQLList(UserType),
        resolve(parentValue){
            //return users
        }
    },
status:{
        type: StatusType,
        args: { id: { type: GraphQLInt } },
        resolve(parentValue, args){
            //return lodash.find(status, { id: args.id })
        }
    },
statusAll: {
        type: new GraphQLList(StatusType),
        resolve(parentValue){
            //return users
        }
    }
    }
});

module.exports = new GraphQLSchema({
query: RouteQuery
})

This code run succesfully but when i try to separate these into multiple files: the const StatusType & UserType like the following case:
the StatusType is on StatusType.js file and the UserType is on UserType.js file

StatuType.js file:

const graphQL = require('graphql');
const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLID, GraphQLSchema, GraphQLList } = graphQL;
const UserType = require('./UserType')
const StatusType = new GraphQLObjectType({
name: 'Status',
fields: () => ({
    id: { type: GraphQLInt },
    statusName: { type: GraphQLString },
    user: {
        type: new GraphQLList(UserType),
        resolve(parentValue, args){
            //return users.filter(user => user.status === parentValue.id);
        }
    }
})
});
module.exports = StatusType;

UserType.js file:

const graphQL = require('graphql');
const { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLID, GraphQLSchema, GraphQLList } = graphQL;
const StatusType = require('./StatusType')

const UserType = new GraphQLObjectType({
name: 'User',
fields: () => ({
    id: { type: GraphQLString },
    username: { type: GraphQLString },
    mail: { type: GraphQLString },
    password: { type: GraphQLString },
    status: { 
        type: StatusType,
        resolve(parentValue, args){
            //return lodash.find(status, { id: parentValue.status })
        }
    },
})
});
module.exports = UserType;

And on the Schema.js file i include these 2 like that:

const StatusType = require('./StatusType');
const UserType = require('./UserType');

so instead of putting the all code on the same file, i putted the StatusType and UserType on respective files.

but when i run this code, i got this error:

enter image description here

So i don’t know what the problem here :/

But when i’m tring to console.log the const UserType = require('./UserType') i got User as response 😮 like when it was on the same code on Schema.js