parse-community / parse-community/parse-server

SchemaController.getAllClasses accepts parameter with wrong type

Open
#7,677 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Issue Checklist
Issue Description

When I was reading the source code, I found two mistakes when calling SchemaController.getAllClasses.

getAllClasses accepts a object with a key named clearCache.

getAllClasses(options: LoadSchemaOptions = { clearCache: false })

But there are two places calling this function with a boolean value.

No.1

In src/Routers/SchemasRouter.js#L19

function getAllSchemas(req) {
  return req.config.database
    .loadSchema({ clearCache: true })
    .then(schemaController => schemaController.getAllClasses(true)) // => #L19
    .then(schemas => ({ response: { results: schemas } }));
}
No.2

In /src/GraphQL/loaders/schemaQueries.js#L63

  const schema = await config.database.loadSchema({ clearCache: true });
  return (await schema.getAllClasses(true)).map(parseClass => ({  // => #L63
    name: parseClass.className,
    schemaFields: transformToGraphQL(parseClass.fields),
  }));
Environment

Server

  • Parse Server version: 5.0.0-beta.1
Logs

n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading getAllClasses and its LoadSchemaOptions declaration, then inspect the calls in src/Routers/SchemasRouter.js and src/GraphQL/loaders/schemaQueries.js. Verify that both REST schema loading and GraphQL schema loading use the expected parameter shape rather than a boolean, and confirm both callers still return their documented schema results.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.