-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CategoryMap, Tag and Media Types (#83)
* BugFix article schema * BugFix content type * Add CategoryMap type * Add Media Type * Add Tag Type * Add article schema file * Add media type enum type * Add getCategory resolver * Update media model * Add getMedia resolver * Add getTag resolver * Link article type to category, tag and media type * Link issue type to article type * Link user type to article and media type * Merge all schemas and types * Update CORS and enable tracing * BugFix ListStyleEnumType * Resolve circular dependency issue
- Loading branch information
Showing
18 changed files
with
380 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @module app.schema.User | ||
* @description User Schema | ||
* | ||
* @requires module:app.schema.scalars | ||
* @requires module:app.schema.UserQuery | ||
* @requires module:app.schema.UserMutation | ||
* | ||
* @version v1 | ||
* @since 0.1.0 | ||
*/ | ||
|
||
const { GraphQLSchema } = require('../scalars'); | ||
const ArticleQuery = require('./article.query'); | ||
const ArticleMutation = require('./article.mutation'); | ||
|
||
module.exports = new GraphQLSchema({ | ||
query: ArticleQuery, | ||
mutation: ArticleMutation, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const CategoryMapModel = require('./categoryMap.model'); | ||
const { APIError } = require('../../helpers/errorHandler'); | ||
|
||
module.exports = { | ||
getCategory: async (_parent, { id, number }, _) => { | ||
try { | ||
if (!id && (!number || number instanceof Number)) { | ||
return APIError('BAD_REQUEST'); | ||
} | ||
|
||
const _category = !id ? await CategoryMapModel.findOne({ number }) : await CategoryMapModel.findById(id); | ||
if (!_category) { | ||
return APIError('NOT_FOUND'); | ||
} | ||
|
||
return _category; | ||
} catch (error) { | ||
return APIError(null, error); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const { | ||
GraphQLObjectType, | ||
// GraphQLScalarType, | ||
// GraphQLUnionType, | ||
// GraphQLInputObjectType, | ||
// GraphQLEnumType, | ||
// GraphQLInterfaceType, | ||
// GraphQLSchema, | ||
// GraphQLNonNull, | ||
// GraphQLError, | ||
// GraphQLList, | ||
GraphQLString, | ||
GraphQLID, | ||
// GraphQLBoolean, | ||
GraphQLInt, | ||
// GraphQLFloat, | ||
// GraphQLDate, | ||
// GraphQLTime, | ||
GraphQLDateTime, | ||
// GraphQLJSON, | ||
// GraphQLJSONObject, | ||
} = require('../scalars'); | ||
// const { getUser } = require('../user/user.resolver'); | ||
// const UserType = require('../user/user.type'); | ||
|
||
const CategoryMapType = new GraphQLObjectType({ | ||
name: 'CategoryMap', | ||
fields: () => ({ | ||
id: { type: GraphQLID }, | ||
number: { type: GraphQLInt }, | ||
name: { type: GraphQLString }, | ||
parent: { | ||
type: new GraphQLObjectType({ | ||
name: 'ParentCategoryMap', | ||
fields: () => ({ | ||
number: { type: GraphQLInt }, | ||
referenceID: { type: CategoryMapType }, | ||
}), | ||
}), | ||
}, | ||
}), | ||
|
||
createdAt: { type: GraphQLDateTime }, | ||
createdBy: { type: GraphQLID }, | ||
// createdByUser: { | ||
// type: UserType, | ||
// resolve: (parent, _, context, info) => getUser(null, { id: parent.createdBy }, context, info), | ||
// }, | ||
updatedAt: { type: GraphQLDateTime }, | ||
updatedBy: { type: GraphQLID }, | ||
// updatedByUser: { | ||
// type: UserType, | ||
// resolve: (parent, _, context, info) => getUser(null, { id: parent.updatedBy }, context, info), | ||
// }, | ||
schemaVersion: { type: GraphQLInt }, | ||
}); | ||
|
||
module.exports = CategoryMapType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.