I've been trying to make this one work. I am currently learning Apollo Server and GraphQL. I went to different documentations but I can't seem to find an answer. Here's what I am trying to do.
I have usertypes.js and here's the code snippet:
const { gql } = require('apollo-server');
const UserTypeDefs = gql`
type User {
_id: ID!,
username: String!,
password: String!,
}
`;
module.exports = UserTypeDefs;
And on my logintypes.js:
const { gql } = require('apollo-server');
const { UserTypeDefs } = require('./usertypes.js')
const LoginTypeDefs = gql`
type LoginResponse {
user: UserTypeDefs.User //this is not working. :(
}
extend type Mutation {
login(username: String!, password: String!): LoginResponse!
}
`;
module.exports = LoginTypeDefs;
Any help is appreciated. I don't want to declare my type User again in my logintypes.js as much as possible.
Thank you in advance.