Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import dataProvider from '../../models/dataProvider'
import { checkPermissionsOf } from '../../middleware/requirePermissionsOf'
const cateInputFields = {
name: {
type: new GraphQLNonNull(GraphQLString)
},
slug: {
type: new GraphQLNonNull(GraphQLString)
},
description: {
type: GraphQLString
}
}
export const AddCategoryMutation = mutationWithClientMutationId({
name: 'AddCategory',
inputFields: cateInputFields,
outputFields: {
_id: {
type: GraphQLString
}
},
mutateAndGetPayload: async (args, req) => {
if (req.user.role !== 'admin') {
return Promise.reject(new Error('Require admin permission!'))
}
return dataProvider.Category.utils.save({
...args
}).then(res => {
return res.toObject()
})
const {
addTodo,
changeTodoStatus,
getTodo,
getTodos,
getViewer,
markAllTodos,
removeCompletedTodos,
removeTodo,
renameTodo,
} = require('../database');
const { GraphQLTodoEdge, GraphQLUser, GraphQLTodo } = require('./types');
const { fromGlobalId_unibet } = require('./unibetIds');
const GraphQLAddTodoMutation = mutationWithClientMutationId({
name: 'AddTodo',
inputFields: {
text: { type: new GraphQLNonNull(GraphQLString) },
},
outputFields: {
todoEdge: {
type: GraphQLTodoEdge,
resolve: async ({ localTodoId }) => {
const todos = await getTodos();
const todo = todos.find(t => t.id === localTodoId);
return {
cursor: cursorForObjectInConnection(todos, todo),
node: todo,
};
},
},
const quotesLibrary = { type: QuotesLibraryType };
const queryType = new GraphQLObjectType({
name: 'RootQuery',
fields: {
node: nodeField,
quotesLibrary: {
type: QuotesLibraryType,
description: 'The Quotes Library',
resolve: () => quotesLibrary
}
}
});
const thumbsUpMutation = mutationWithClientMutationId({
name: 'ThumbsUpMutation',
inputFields: {
quoteId: { type: GraphQLString }
},
outputFields: {
quote: {
type: QuoteType,
resolve: obj => obj
}
},
mutateAndGetPayload: (params, { db }) => {
const { id } = fromGlobalId(params.quoteId);
return Promise.resolve(
db.collection('quotes').updateOne(
{ _id: ObjectID(id) },
{ $inc: { likesCount: 1 } }
};
},
interfaces: [nodeInterface]
});
const {
connectionType: TodoConnection,
edgeType: GraphQLTodoEdge
} = connectionDefinitions({
name: "Todo",
nodeType: TodoType
});
export { TodoConnection, GraphQLTodoEdge };
export const AddTodoMutation = mutationWithClientMutationId({
name: "AddTodoMutation",
inputFields: {
text: { type: new GraphQLNonNull(GraphQLString) }
},
outputFields: {
todoEdge: {
type: GraphQLTodoEdge,
async resolve({ todoId }) {
const [todo, todos] = await Promise.all([
todosDAO.getById(todoId),
todosDAO.all()
]);
return {
cursor: cursorForObjectInConnection(todos, todo),
node: todo
},
interfaces: [nodeInterface],
});
const GraphQLRoot = new GraphQLObjectType({
name: 'Root',
fields: {
viewer: {
type: GraphQLUser,
resolve: getViewer,
},
node: nodeField,
},
});
const GraphQLAddTodoMutation = mutationWithClientMutationId({
name: 'AddTodo',
inputFields: {
text: { type: new GraphQLNonNull(GraphQLString) },
},
outputFields: {
viewer: {
type: GraphQLUser,
resolve: getViewer,
},
todoEdge: {
type: GraphQLTodoEdge,
resolve: ({ todoId }) => {
const todo = getTodo(todoId);
return {
cursor: cursorForObjectInConnection(getTodos(), todo),
node: todo,
} from '../../../../constants/index'
import GraphQLUserRole from '../types/GraphQLUserRole'
const PossibleErrors = new GraphQLEnumType({
name: 'UpdateUserErrors',
values: {
USER_IS_NOT_LOGGED: {
value: USER_IS_NOT_LOGGED,
},
USER_NOT_FOUND: {
value: USER_NOT_FOUND
}
},
})
const UpdateUserMutation = mutationWithClientMutationId({
name: 'UpdateUserMutation',
description: `this mutation updates a user`,
inputFields: {
id: {
type: new GraphQLNonNull(GraphQLID),
description: `id of user`
},
email: {
type: GraphQLEmail,
description: 'email of user'
},
name: {
type: GraphQLString,
description: 'name of user'
},
role: {
'use strict';
import { userType } from './user-type';
import { insertWidgetInputType } from './insert-widget-input-type';
import { WidgetEdge } from '../widget-connection';
import { mutationWithClientMutationId, cursorForObjectInConnection } from 'graphql-relay';
import { insertWidget, getUser, getWidgets } from '../../database';
export const insertWidgetMutation = mutationWithClientMutationId({
name: 'InsertWidget',
inputFields: {
widget: { type: insertWidgetInputType }
},
outputFields: {
user: {
type: userType,
resolve: () => getUser(1)
},
newWidgetEdge: {
type: WidgetEdge,
resolve: widget => ({
cursor: cursorForObjectInConnection(getWidgets(), widget),
node: widget })
}
},
import { graphql } from "graphql"
import { mutationWithClientMutationId } from "graphql-relay"
import { OrderOrFailureUnionType } from "./types/order_or_error_union"
import { SellerOrderFields } from "./query_helpers"
import gql from "lib/gql"
import { extractEcommerceResponse } from "./extractEcommerceResponse"
import { RejectOfferMutationInputType } from "./types/reject_offer_mutation_input_type"
import { ResolverContext } from "types/graphql"
export const SellerRejectOfferMutation = mutationWithClientMutationId<
any,
any,
ResolverContext
>({
name: "sellerRejectOffer",
description: "Rejects an offer",
inputFields: RejectOfferMutationInputType.getFields(),
outputFields: {
orderOrError: {
type: OrderOrFailureUnionType,
},
},
mutateAndGetPayload: ({ offerId, rejectReason }, context) => {
const { accessToken, exchangeSchema } = context
if (!accessToken) {
return new Error("You need to be signed in to perform this action")
type: GraphQLString
}
},
mutateAndGetPayload: async (args, req) => {
if (req.user.role !== 'admin') {
return Promise.reject(new Error('Require admin permission!'))
}
return dataProvider.Category.utils.save({
...args
}).then(res => {
return res.toObject()
})
}
})
export const UpdateCategoryMutation = mutationWithClientMutationId({
name: 'UpdateCategory',
inputFields: {
...cateInputFields,
id: {
type: new GraphQLNonNull(GraphQLID)
}
},
outputFields: {
ok: {
type: GraphQLInt
},
n: {
type: GraphQLInt
},
nModified: {
type: GraphQLInt
authenticity_certificate: authenticityCertificate,
dimensions_metric: dimensionsMetric,
edition_number: editionNumber,
edition_size: editionSize,
location_city: locationCity,
location_country: locationCountry,
location_state: locationState,
user_id: userID,
..._submission,
}
if (!submissionUpdateLoader) return null
return submissionUpdateLoader(submission.id, submission)
},
}
export default mutationWithClientMutationId(config)