Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

fix(core): make `metadata` available in production (#3714)

Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>

Changed files
+5 -16
.changeset
scripts
+5
.changeset/fluffy-starfishes-unite.md
···
···
+
---
+
'@urql/core': minor
+
---
+
+
Remove `addMetadata` transform where we'd strip out metadata for production environments, this particularly affects `OperationResult.context.metadata.cacheOutcome`
-16
scripts/babel/transform-debug-target.mjs
···
process.env.NODE_ENV !== 'production' ? NODE : undefined
`.trim();
-
const noopTransformTemplate = `
-
process.env.NODE_ENV !== 'production' ? NODE : FALLBACK
-
`.trim();
-
const plugin = ({ template, types: t }) => {
const wrapWithDevCheck = template.expression(warningDevCheckTemplate, {
placeholderPattern: /^NODE$/,
-
});
-
-
const wrapWithNoopTransform = template.expression(noopTransformTemplate, {
-
placeholderPattern: /^(NODE|FALLBACK)$/,
});
let name = 'unknownExchange';
···
}
path.replaceWith(wrapWithDevCheck({ NODE: path.node }));
-
} else if (path.node.callee.name === 'addMetadata') {
-
path.node[visited] = true;
-
path.replaceWith(
-
wrapWithNoopTransform({
-
NODE: path.node,
-
FALLBACK: path.node.arguments[0],
-
})
-
);
}
},
},
···
process.env.NODE_ENV !== 'production' ? NODE : undefined
`.trim();
const plugin = ({ template, types: t }) => {
const wrapWithDevCheck = template.expression(warningDevCheckTemplate, {
placeholderPattern: /^NODE$/,
});
let name = 'unknownExchange';
···
}
path.replaceWith(wrapWithDevCheck({ NODE: path.node }));
}
},
},