Skip to content

Commit

Permalink
add data time graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
lane711 committed May 12, 2021
1 parent 1cca763 commit 0b3d57f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 51 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -60,6 +60,7 @@
"font-awesome": "^4.7.0",
"formiojs": "^4.13.0",
"graphql": "^14.7.0",
"graphql-iso-date": "^3.6.1",
"graphql-request": "^3.3.0",
"graphql-type-json": "^0.3.2",
"inquirer": "^7.3.3",
Expand Down
40 changes: 0 additions & 40 deletions s3-test.js

This file was deleted.

1 change: 1 addition & 0 deletions server.js
Expand Up @@ -34,6 +34,7 @@ mongoose.set('useCreateIndex', true);
mongoose.connect(process.env.MONGODB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
});
const User = require("./server/schema/models/user");

Expand Down
2 changes: 1 addition & 1 deletion server/modules/user/models/user.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions server/page-builder/js/page-builder.js
Expand Up @@ -683,6 +683,8 @@ async function editInstanceUser(payload, refresh, contentType = "content") {
// }

await dataService.userUpdate(payload);

fullPageUpdate();
//update user
// return axiosInstance
// .put(`/api/${contentType}/${id}`, payload)
Expand Down
26 changes: 17 additions & 9 deletions server/schema/schema.js
Expand Up @@ -22,6 +22,12 @@ const {
GraphQLBoolean,
} = graphql;

const {
GraphQLDate,
GraphQLTime,
GraphQLDateTime
} = require('graphql-iso-date');

//Schema defines data on the Graph like object types(book type), relation between
//these object types and describes how it can reach into the graph to interact with
//the data to retrieve or mutate the data
Expand All @@ -32,12 +38,14 @@ const UserType = new GraphQLObjectType({
id: { type: GraphQLID },
username: { type: GraphQLString },
password: { type: GraphQLString },
book: {
type: new GraphQLList(UserType),
resolve(parent, args) {
return User.find({ userId: parent.id });
},
},
lastLoginOn: { type: GraphQLDateTime},
profile: { type: GraphQLJSONObject },
// book: {
// type: new GraphQLList(UserType),
// resolve(parent, args) {
// return User.find({ userId: parent.id });
// },
// },
}),
});

Expand Down Expand Up @@ -385,7 +393,7 @@ const Mutation = new GraphQLObjectType({
let userDoc = User.findByIdAndUpdate(args.id, {
lastLoginOn: new Date(),
profile: profileObj,
});
}, false);
userDoc.exec();
},
},
Expand Down Expand Up @@ -440,14 +448,14 @@ const Mutation = new GraphQLObjectType({
let tagDoc = Tag.findByIdAndUpdate(
args.tagId,
{ $push: { contents: args.contentId } },
{ new: true, useFindAndModify: false }
{ new: true }
);
tagDoc.exec();

let contentDoc = Content.findByIdAndUpdate(
args.contentId,
{ $push: { tags: args.tagId } },
{ new: true, useFindAndModify: false }
{ new: true }
);
contentDoc.exec();

Expand Down
3 changes: 3 additions & 0 deletions server/services/auth.service.js
Expand Up @@ -96,6 +96,9 @@ module.exports = authService = {
}

req.session.userId = user.id;

//TODO: add roles
userService.getRoles()

if(!req.session.returnTo){
return res.redirect('/admin');
Expand Down
2 changes: 1 addition & 1 deletion server/services/data.service.js
Expand Up @@ -125,7 +125,7 @@ if (typeof module !== "undefined" && module.exports) {
`,
});

return result.data.data.contentType;
return result.data;
}),
(exports.rolesGet = async function () {
let result = await this.getAxios().post(apiUrl, {
Expand Down
2 changes: 2 additions & 0 deletions server/services/user.service.js
Expand Up @@ -89,6 +89,8 @@ module.exports = userService = {
user(id:"${id}"){
id
username
lastLoginOn
profile
}
}
`;
Expand Down

0 comments on commit 0b3d57f

Please sign in to comment.