Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mutateAndGetPayload: async (data, { user }: GraphQLContext) => {
if (!user) return { error: 'You must be authenticated' }
const { id } = fromGlobalId(data.id)
const question = await QuestionModel.findById(id)
if (!question) return { error: "Question doesn't exists" }
// eslint-disable-next-line eqeqeq
if (question.author.toString() != user._id) {
return { error: "You don't own this question" }
}
await QuestionModel.findByIdAndDelete(id)
return { error: null }
},
outputFields: {
Node: nodeDefinitions((globalId) => {
const { type, id } = fromGlobalId(globalId)
console.log('Warning-------------------- node id Fetcher not implement' + type + ' ' + id)
}, (obj) => {
const type = obj._fieldType
export function cursorToPk(cursor) {
const { id: resourceId } = fromGlobalId(cursorToNodeId(cursor));
return resourceId;
}
async (globalId) => {
const { type: name, id } = fromGlobalId(globalId);
const endpoint = getEndpoint(name);
const resource = await endpoint.get(id);
return resource || null;
},
(obj) => {
(globalId) => {
const target = Relay.fromGlobalId(globalId);
if (target.type === 'Image') {
return (new myImages()).getById(target.id);
} else {
return null;
}
},
(obj) => {
mutateAndGetPayload: ({ text, completed, id }) => {
let { type, id: todoItemId } = fromGlobalId(id);
let targetTodoItem = todoItems.find(t => t.id === parseInt(todoItemId, 10));
if (!targetTodoItem || type !== "TodoItem") {
return {
updatedTodoItem: null
};
}
targetTodoItem.text = text;
targetTodoItem.completed = completed;
return {
updatedTodoItem: targetTodoItem
};
}
});
resolve: (obj, args, context) => {
const { id } = fromGlobalId(args.id);
return UserLoader.load(context, id);
},
},