a year ago
When changing my graphql.schema and deploying it via github pushes to the main branch, the schema at /graphiql is not updating.
On local it works just fine. In my Dockerfile, I have the following settings to make sure a deployment starts off fresh:
CMD php artisan config:cache \
&& php artisan route:cache \
&& php artisan view:cache \
&& php artisan lighthouse:clear-cache \
&& php artisan lighthouse:cache \
&& (php artisan migrate --force || true) \
&& apache2-foreground
I've tried restarting and redeploying to no avail. The Graphql schema available at /graphiql is not updating and I've confirmed the /graphql endpoint actually doesn't have the updated schema.
2 Replies
a year ago
Apologies but this looks like an issue with the application level code. Due to volume, we can only answer platform level issues here
I've made this thread public so that the community might be able to help
Status changed to Awaiting User Response Railway • 11 months ago
a year ago
Understanding the GraphQL Lighthouse Cache Issue I Faced
Hey everyone, I wanted to follow up with the solution to my GraphQL schema cache issue since others might encounter it too.
The Problem I Discovered
Despite pushing schema changes to my main branch and Railway rebuilding the container, my GraphQL schema wasn't updating at /graphiql. Some schema elements were there, but my newest additions were missing.
The Root Cause
After investigating, I discovered the issue was in my Dockerfile's CMD configuration:
CMD php artisan config:cache \
&& php artisan route:cache \
&& php artisan view:cache \
&& php artisan lighthouse:clear-cache \
&& php artisan lighthouse:cache \
&& (php artisan migrate --force || true) \
&& apache2-foreground
This sequence creates a direct conflict:
My
.envhadLIGHTHOUSE_SCHEMA_CACHE_ENABLE="false"to prevent cachingBut I was explicitly running
lighthouse:cacheduring container startup
What's happening: The lighthouse:cache command was generating a cached version of whatever schema existed when the Docker image was built. Then Lighthouse would use this cached version instead of reading the actual schema file, effectively ignoring my environment variable settings.
The Solution
The fix is simple - modify the CMD in the Dockerfile to only use caching in production:
CMD php artisan config:cache \
&& php artisan route:cache \
&& php artisan view:cache \
&& php artisan lighthouse:clear-cache \
&& (if [ "$APP_ENV" = "production" ]; then php artisan lighthouse:cache; fi) \
&& (php artisan migrate --force || true) \
&& apache2-foreground
This way:
In staging/development: Schema cache is cleared but not rebuilt
In production: Schema is cleared and then cached for performance
Why This Works
When you don't rebuild the cache, Lighthouse falls back to reading your schema file directly. This means as soon as your deployment contains the updated schema file, your API will reflect those changes.
Hope this helps anyone dealing with similar issues!