When using the modular content features with Nuxt + Apollo i get console errors ‘heuristic fragment matching going on’. The page renders fine locally despite the errors, and the errors go away on the Netlify dev site, but the SSG has failed to work and if I view the page with javaScript disabled, the page is blank.
Is there an extra step required which would fix the errors and allow the static site version to generate correctly?
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
import introspectionQueryResultData from './fragmentTypes.json'
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData
})
export default new InMemoryCache({ fragmentMatcher })
The strange thing is, as per others on the above thread, just providing a blank schema resolves all of the console warnings and has restored SSG to all of the pages that used modular content. So now if I browse with JS disabled I see the content in the src. Also confirmed by my build times in Netlify jumping up from 2 to 5 mins.
So my fragmentTypes.json file looks like this
{
"__schema": {
"types": [
]
}
}
I suspect this will come back and bite me at some point but for now I’m going with it : )
But as you said, this solution could lead to some pretty big problems for you in the future.
You can populate your fragmentTypes.json with some automatic graphQL schema generators, the methods to generate this file populated accordingly to your GraphQL schema are discussed a bit here: Using fragments - Client (React) - Apollo GraphQL Docs