MCPcopy Index your code
hub / github.com/parse-community/parse-server / load

Function load

src/GraphQL/loaders/parseClassMutations.js:39–335  ·  view source on GitHub ↗
(parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLClassConfig)

Source from the content-addressed store, hash-verified

37};
38
39const load = function (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLClassConfig) {
40 const className = parseClass.className;
41 const graphQLClassName = transformClassNameToGraphQL(className);
42 const getGraphQLQueryName = graphQLClassName.charAt(0).toLowerCase() + graphQLClassName.slice(1);
43
44 const {
45 create: isCreateEnabled = true,
46 update: isUpdateEnabled = true,
47 destroy: isDestroyEnabled = true,
48 createAlias: createAlias = '',
49 updateAlias: updateAlias = '',
50 destroyAlias: destroyAlias = '',
51 } = getParseClassMutationConfig(parseClassConfig);
52
53 const {
54 classGraphQLCreateType,
55 classGraphQLUpdateType,
56 classGraphQLOutputType,
57 } = parseGraphQLSchema.parseClassTypes[className];
58
59 if (isCreateEnabled) {
60 const createGraphQLMutationName = createAlias || `create${graphQLClassName}`;
61 const createGraphQLMutation = mutationWithClientMutationId({
62 name: `Create${graphQLClassName}`,
63 description: `The ${createGraphQLMutationName} mutation can be used to create a new object of the ${graphQLClassName} class.`,
64 inputFields: {
65 fields: {
66 description: 'These are the fields that will be used to create the new object.',
67 type: classGraphQLCreateType || defaultGraphQLTypes.OBJECT,
68 },
69 },
70 outputFields: {
71 [getGraphQLQueryName]: {
72 description: 'This is the created object.',
73 type: new GraphQLNonNull(classGraphQLOutputType || defaultGraphQLTypes.OBJECT),
74 },
75 },
76 mutateAndGetPayload: async (args, context, mutationInfo) => {
77 try {
78 let { fields } = cloneArgs(args);
79 if (!fields) { fields = {}; }
80 const { config, auth, info } = context;
81
82 const parseFields = await transformTypes('create', fields, {
83 className,
84 parseGraphQLSchema,
85 originalFields: args.fields,
86 req: { config, auth, info },
87 });
88
89 const createdObject = await objectsMutations.createObject(
90 className,
91 parseFields,
92 config,
93 auth,
94 info
95 );
96 const selectedFields = getFieldNames(mutationInfo)

Callers

nothing calls this directly

Calls 12

cloneArgsFunction · 0.90
transformTypesFunction · 0.90
extractKeysAndIncludeFunction · 0.90
getOnlyRequiredFieldsFunction · 0.85
filterDeletedFieldsFunction · 0.85
filterMethod · 0.80
addGraphQLTypeMethod · 0.80
addGraphQLMutationMethod · 0.80
createObjectMethod · 0.65
handleErrorMethod · 0.45

Tested by

no test coverage detected