fix: scope locale context to current query and not reuse globally #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#209 describe how sometimes nested fields don't honor
locale
settings. This happens because thecontext.sourceDatocms
object is actually reused between all the queries that run in given process and state there is scope to just field paths within the query. Gatsby can execute multiple queries in parallel (especially for the builds as it does batching of all queries), so this shared state object is a problem as one query for one page might change the context that query for other page rely on.Proposed fix provide fresh
locale
andlocaleFallback
for each query seperately - I implemented this in shortest way possible, there is opportunity for some optimisation as right now there is a lot of repeated.get
lookups which I kept for visibilty and easier to follow proposed changesPossibly fixes #209