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

Function load

src/GraphQL/loaders/schemaQueries.js:20–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18};
19
20const load = parseGraphQLSchema => {
21 parseGraphQLSchema.addGraphQLQuery(
22 'class',
23 {
24 description: 'The class query can be used to retrieve an existing object class.',
25 args: {
26 name: schemaTypes.CLASS_NAME_ATT,
27 },
28 type: new GraphQLNonNull(schemaTypes.CLASS),
29 resolve: async (_source, args, context) => {
30 try {
31 const { name } = cloneArgs(args);
32 const { config, auth } = context;
33
34 enforceMasterKeyAccess(auth, config);
35
36 const schema = await config.database.loadSchema({ clearCache: true });
37 const parseClass = await getClass(name, schema);
38 return {
39 name: parseClass.className,
40 schemaFields: transformToGraphQL(parseClass.fields),
41 };
42 } catch (e) {
43 parseGraphQLSchema.handleError(e);
44 }
45 },
46 },
47 true,
48 true
49 );
50
51 parseGraphQLSchema.addGraphQLQuery(
52 'classes',
53 {
54 description: 'The classes query can be used to retrieve the existing object classes.',
55 type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(schemaTypes.CLASS))),
56 resolve: async (_source, _args, context) => {
57 try {
58 const { config, auth } = context;
59
60 enforceMasterKeyAccess(auth, config);
61
62 const schema = await config.database.loadSchema({ clearCache: true });
63 return (await schema.getAllClasses(true)).map(parseClass => ({
64 name: parseClass.className,
65 schemaFields: transformToGraphQL(parseClass.fields),
66 }));
67 } catch (e) {
68 parseGraphQLSchema.handleError(e);
69 }
70 },
71 },
72 true,
73 true
74 );
75};
76
77export { getClass, load };

Callers

nothing calls this directly

Calls 8

cloneArgsFunction · 0.90
enforceMasterKeyAccessFunction · 0.90
transformToGraphQLFunction · 0.90
getClassFunction · 0.85
addGraphQLQueryMethod · 0.80
loadSchemaMethod · 0.80
getAllClassesMethod · 0.65
handleErrorMethod · 0.45

Tested by

no test coverage detected