ERROR: Apps aren't loaded yet

For some reason I get this error and I tried everything to solve it that is you know are there it is not being solved and previously I had to restart my whole project but my current project is so large that I cannot afford to restart fresh can anyone help me.

Welcome @Suraj !

There are different reasons why this error might appear, but the most common cause that I see is that this happens when someone tries to execute a query at the “module” level and not within an appropriate function.