diff --git a/.changeset/nasty-vans-doubt.md b/.changeset/nasty-vans-doubt.md new file mode 100644 index 00000000..4241b3ac --- /dev/null +++ b/.changeset/nasty-vans-doubt.md @@ -0,0 +1,5 @@ +--- +'scoobie': patch +--- + +CodeBlock: Update GraphQL playground links to work with multiple variables combinations diff --git a/src/components/CodeBlock.tsx b/src/components/CodeBlock.tsx index 5d98ffa5..c43c729e 100644 --- a/src/components/CodeBlock.tsx +++ b/src/components/CodeBlock.tsx @@ -64,9 +64,15 @@ export const CodeBlock = ({ const child = children[index.value] ?? children[0]; + const variableIndexBlock = [index.value, 1].find( + (idx) => + children[idx]?.language?.startsWith('json') && + children[idx]?.label?.startsWith('Variables'), + ); + const jsoncVariables = - children[0].language === 'graphql' && children[1]?.label === 'Variables' - ? children[1].code + children[0].language === 'graphql' && variableIndexBlock !== undefined + ? children[variableIndexBlock].code : undefined; const variables =