Disabling partial responses but schema awareness #3835
-
|
Hello urql community! Partial results are causing a lot of issues in our application. Unfortunately, the docs and API don't seem to mention a possibility to disable it. I would apreciate any hints that could point me into the right direction. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
While digging through the source code, I found an undocumented option: It is possible to test out the option with this function: /**
* Generates a PossibleTypesConfig from a GraphQL introspection schema.
*
* This function extracts abstract type (UNION and INTERFACE) to concrete type
* mappings from the introspection schema, allowing Graphcache to match
* fragments deterministically without heuristic fragment matching.
*
* @param introspectionSchema - The introspection schema containing __schema.types
* @returns A mapping of abstract type names to arrays of concrete type names
*/
function generatePossibleTypes(introspectionSchema: typeof schema): PossibleTypesConfig {
const possibleTypes: PossibleTypesConfig = {};
for (const type of introspectionSchema.__schema.types) {
if ((type.kind === "UNION" || type.kind === "INTERFACE") && type.possibleTypes != null) {
possibleTypes[type.name] = type.possibleTypes.map((t) => t.name);
}
}
return possibleTypes;
}
const exchange = cacheExchange({
possibleTypes: generatePossibleTypes(schema),
});This still includes the schema in the bundle but it allowed me to try out the option without a big change or having to write a utility that generate possible types. |
Beta Was this translation helpful? Give feedback.
While digging through the source code, I found an undocumented option:
possibleTypes. It can be used to enable deterministic fragment matching without passing a schema, thus disabling all other features of schema awareness. This is exactly what I was looking for.It is possible to test out the option with this function: