MCPcopy Create free account
hub / github.com/parse-community/parse-server / load

Function load

src/GraphQL/loaders/parseClassQueries.js:45–142  ·  view source on GitHub ↗
(parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLClassConfig)

Source from the content-addressed store, hash-verified

43};
44
45const load = function (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLClassConfig) {
46 const className = parseClass.className;
47 const graphQLClassName = transformClassNameToGraphQL(className);
48 const {
49 get: isGetEnabled = true,
50 find: isFindEnabled = true,
51 getAlias: getAlias = '',
52 findAlias: findAlias = '',
53 } = getParseClassQueryConfig(parseClassConfig);
54
55 const {
56 classGraphQLOutputType,
57 classGraphQLFindArgs,
58 classGraphQLFindResultType,
59 } = parseGraphQLSchema.parseClassTypes[className];
60
61 if (isGetEnabled) {
62 const lowerCaseClassName = graphQLClassName.charAt(0).toLowerCase() + graphQLClassName.slice(1);
63
64 const getGraphQLQueryName = getAlias || lowerCaseClassName;
65
66 parseGraphQLSchema.addGraphQLQuery(getGraphQLQueryName, {
67 description: `The ${getGraphQLQueryName} query can be used to get an object of the ${graphQLClassName} class by its id.`,
68 args: {
69 id: defaultGraphQLTypes.GLOBAL_OR_OBJECT_ID_ATT,
70 options: defaultGraphQLTypes.READ_OPTIONS_ATT,
71 },
72 type: new GraphQLNonNull(classGraphQLOutputType || defaultGraphQLTypes.OBJECT),
73 async resolve(_source, args, context, queryInfo) {
74 try {
75 return await getQuery(
76 parseClass,
77 _source,
78 cloneArgs(args),
79 context,
80 queryInfo,
81 parseGraphQLSchema.parseClasses
82 );
83 } catch (e) {
84 parseGraphQLSchema.handleError(e);
85 }
86 },
87 });
88 }
89
90 if (isFindEnabled) {
91 const lowerCaseClassName = graphQLClassName.charAt(0).toLowerCase() + graphQLClassName.slice(1);
92
93 const findGraphQLQueryName = findAlias || pluralize(lowerCaseClassName);
94
95 parseGraphQLSchema.addGraphQLQuery(findGraphQLQueryName, {
96 description: `The ${findGraphQLQueryName} query can be used to find objects of the ${graphQLClassName} class.`,
97 args: classGraphQLFindArgs,
98 type: new GraphQLNonNull(classGraphQLFindResultType || defaultGraphQLTypes.OBJECT),
99 async resolve(_source, args, context, queryInfo) {
100 try {
101 // Deep copy args to avoid internal re assign issue
102 const { where, order, skip, first, after, last, before, options } = cloneArgs(args);

Callers

nothing calls this directly

Calls 3

getParseClassQueryConfigFunction · 0.85
addGraphQLQueryMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…