Skip to content

SchemaController.getAllClasses accepts parameter with wrong type #7677

Open

Description

@ThornWu

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

Activity

  1. parse-github-assistant commented on Nov 4, 2021

    @parse-github-assistant

    Thanks for opening this issue!

    • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.
  2. mtrezza commented on Nov 4, 2021

    @mtrezza
    Member

    It seems you are correct; in 0a6eaf3 the bool has been replaced by object, but the lines you mentioned seem to have been forgotten while others were converted.

    What was the potential impact of that? Tests usually pass.

  3. ThornWu commented on Nov 5, 2021

    @ThornWu
    ContributorAuthor

    When our team switch our deploy method from docker-compose to helm chart(with a single pod), we found the hot reload of schema is broken. The database is updated, but the schema cache not. Then I found GET /schemas seems to designed for getting the newest schema by refreshing cache, so I was going to call this router manually. The only thing I need to first is adding a patch to the function getAllSchemas. I did it and it was working.

    Currently I have no time to find the exact reason why the helm chart way is broken, but I ensure all PARSE config are same.

    So the actual problem I met is in some case, schema cache doesn't refresh. I just bypassed the problem and found these two mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions