From 90f6cde701405a4450d38aa59e17045100aebc92 Mon Sep 17 00:00:00 2001 From: Stefano Magni Date: Tue, 8 Nov 2022 16:02:55 +0100 Subject: [PATCH] console: Fix the broken GraphiQL REST button (close #9189) PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6779 GitOrigin-RevId: 94db764b17e5c7700a1ec501b5f6d4417f3af4f0 --- .../api-graphiql/heap.api-graphiql.integration.test.ts | 4 ++++ .../Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/console/cypress/e2e/tracing/api-graphiql/heap.api-graphiql.integration.test.ts b/console/cypress/e2e/tracing/api-graphiql/heap.api-graphiql.integration.test.ts index d8fa137532c..b1541d4797b 100644 --- a/console/cypress/e2e/tracing/api-graphiql/heap.api-graphiql.integration.test.ts +++ b/console/cypress/e2e/tracing/api-graphiql/heap.api-graphiql.integration.test.ts @@ -31,6 +31,10 @@ describe('Tracing GraphiQL plugins usage', () => { }); it('When the users interact with GraphiQL, then some custom Heap events must be traced', () => { + // ATTENTION: This test checks only that the events are sent, not that the involved features work! + // For example: the query used in this test is not valid, but the test passes anyway since it + // checks for the events only + // -------------------- cy.log('**--- Click the GraphiQL Prettify button**'); cy.get('.graphiql-container').within(() => { diff --git a/console/src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js b/console/src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js index 2eb391da5a8..167d24f3916 100644 --- a/console/src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js +++ b/console/src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js @@ -171,7 +171,7 @@ class GraphiQLWrapper extends Component { dispatch(_push(getActionsCreateRoute())); }; - const routeToREST = gqlProps => () => { + const createRouteToREST = gqlProps => () => { const { query, schema } = graphiqlContext.state; setLSItem(LS_KEYS.graphiqlQuery, query); if (!query || !schema || !gqlProps.query || !isQueryValid(query)) { @@ -239,6 +239,8 @@ class GraphiQLWrapper extends Component { // get toolbar buttons const getGraphiqlButtons = () => { + const routeToREST = createRouteToREST(graphiqlProps); + const buttons = [ { label: 'Prettify', @@ -274,7 +276,7 @@ class GraphiQLWrapper extends Component { title: 'REST Endpoints', onClick: () => { trackGraphiQlToolbarButtonClick('REST'); - routeToREST(graphiqlProps); + routeToREST(); }, }, ];