diff --git a/packages/grafnode-components/src/components/RequestTabPanel/index.js b/packages/grafnode-components/src/components/RequestTabPanel/index.js index 7c25a3730..abdc576d2 100644 --- a/packages/grafnode-components/src/components/RequestTabPanel/index.js +++ b/packages/grafnode-components/src/components/RequestTabPanel/index.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import find from 'lodash/find'; -import { rawRequest, gql } from 'graphql-request'; import QueryUrl from '../QueryUrl'; import RequestPane from '../RequestPane'; import ResponsePane from '../ResponsePane'; @@ -19,13 +18,11 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re } let asideWidth = 200; - let [data, setData] = useState({}); let [url, setUrl] = useState('https://api.spacex.land/graphql'); let { schema } = useGraphqlSchema('https://api.spacex.land/graphql'); let [query, setQuery] = useState(''); - let [isLoading, setIsLoading] = useState(false); const [leftPaneWidth, setLeftPaneWidth] = useState(500); const [rightPaneWidth, setRightPaneWidth] = useState(window.innerWidth - 700 - asideWidth); const [dragging, setDragging] = useState(false); @@ -83,33 +80,11 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re } const runQuery = async () => { - const query = gql`${item.request.body.graphql.query}`; - - setIsLoading(true); - const timeStart = Date.now(); - const { data, errors, extensions, headers, status } = await rawRequest(item.request.url, query); - const timeEnd = Date.now(); - setData(data); - setIsLoading(false); - console.log(headers); - - if(data && !errors) { - // todo: alternate way to calculate length when content length is not present - const size = headers.map["content-length"]; - - dispatch({ - type: actions.RESPONSE_RECEIVED, - response: { - data: data, - headers: Object.entries(headers.map), - size: size, - status: status, - duration: timeEnd - timeStart - }, - requestTab: focusedTab, - collectionId: collection.id - }); - } + dispatch({ + type: actions.SEND_REQUEST, + requestTab: focusedTab, + collectionId: collection ? collection.id : null + }); }; return ( @@ -148,7 +123,7 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re diff --git a/packages/grafnode-components/src/components/RequestTabs/StyledWrapper.js b/packages/grafnode-components/src/components/RequestTabs/StyledWrapper.js index 532da8997..af29e3a7a 100644 --- a/packages/grafnode-components/src/components/RequestTabs/StyledWrapper.js +++ b/packages/grafnode-components/src/components/RequestTabs/StyledWrapper.js @@ -22,7 +22,7 @@ const Wrapper = styled.div` padding-right: 0; cursor: pointer; font-size: 0.8125rem; - height: 40px; + height: 38px; .tab-container { width: 100%; diff --git a/packages/grafnode-components/src/components/Welcome/index.js b/packages/grafnode-components/src/components/Welcome/index.js index 76330c750..2c30bd08c 100644 --- a/packages/grafnode-components/src/components/Welcome/index.js +++ b/packages/grafnode-components/src/components/Welcome/index.js @@ -3,9 +3,16 @@ import { IconPlus, IconUpload } from '@tabler/icons'; import StyledWrapper from './StyledWrapper'; const Welcome = ({dispatch, actions}) => { - const handleClick = () => { + const newGraphqlRequest = () => { dispatch({ - type: actions.ADD_NEW_HTTP_REQUEST + type: actions.ADD_NEW_GQL_REQUEST, + requestType: 'graphql' + }); + }; + const newHttpRequest = () => { + dispatch({ + type: actions.ADD_NEW_HTTP_REQUEST, + requestType: 'http' }); }; @@ -36,12 +43,12 @@ const Welcome = ({dispatch, actions}) => {