Skip to content

Commit

Permalink
fix(operation-ids): always generate operation id based on inlined que…
Browse files Browse the repository at this point in the history
…ries

Otherwise different operation maps won't match.
  • Loading branch information
pmelab committed Oct 25, 2024
1 parent 1f8f9e7 commit b13f525
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe('mode: map', () => {
);
expect(JSON.parse(result)).toMatchInlineSnapshot(`
{
"HomeQuery:c25b93055bb9dce4d474a8e9031df3842a686ad4ad1b3ce2806ef528eb5b1c47": "query Home {
"HomeQuery:9e615243c0c61d86531091aa395544df99db822d94d50a761c2809d61caf3164": "query Home {
loadPage(path: "/") {
...Page
related {
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('mode: map', () => {
);
expect(JSON.parse(result)).toMatchInlineSnapshot(`
{
"HomeQuery:fe7f24087d5deae03464a1e58e1c5a50cd6dbbbf4b4e68c41e5f6b9f2f947d3c": "query Home {
"HomeQuery:7f81601e1df0c179be7354f3f834201b9615d0ea191d4ba5f83bb45b0bfe052d": "query Home {
loadPage(path: "/") {
...Page
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const plugin: PluginFunction<any, string> = async (
const idMap = new Map<string, string>();
visit(allAst, {
OperationDefinition(node) {
const id = queryId(node, print(inlineFragments(node, fragmentMap)));
const query = [
print(
config.fragments === 'inline'
Expand All @@ -87,7 +88,6 @@ export const plugin: PluginFunction<any, string> = async (
});
}
const queryString = query.join('\n');
const id = queryId(node, queryString);
operationMap.set(id, queryString);
if (node.name) {
idMap.set(node.name.value, id);
Expand Down

0 comments on commit b13f525

Please sign in to comment.