Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
ba833859
Commit
ba833859
authored
Feb 24, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graphql
parent
0009573d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
6 deletions
+52
-6
graphiql.tsx
pages/graphiql.tsx
+33
-4
GraphQL.tsx
ui/graphQL/GraphQL.tsx
+19
-2
No files found.
pages/graphiql.tsx
View file @
ba833859
import
{
Spinner
}
from
'
@chakra-ui/react
'
;
import
{
Spinner
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
type
{
NextPage
}
from
'
next
'
;
import
dynamic
from
'
next/dynamic
'
;
const
GraphQL
=
dynamic
(()
=>
import
(
'
ui/graphQL/GraphQL
'
),
{
loading
:
()
=>
<
Spinner
/>,
ssr
:
false
,
});
import
Head
from
'
next/head
'
;
import
React
from
'
react
'
;
const
GraphQLPage
:
NextPage
=
()
=>
{
return
<
GraphQL
/>;
import
isBrowser
from
'
lib/isBrowser
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
const
AppsPage
:
NextPage
=
()
=>
{
const
{
colorMode
}
=
useColorMode
();
const
[
show
,
setShow
]
=
React
.
useState
(
true
);
React
.
useEffect
(()
=>
{
if
(
!
show
)
{
// force re-render GraphQL component to apply new theme
setShow
(
true
);
}
},
[
show
]);
React
.
useEffect
(()
=>
{
if
(
isBrowser
())
{
const
graphqlTheme
=
window
.
localStorage
.
getItem
(
'
graphiql:theme
'
);
if
(
graphqlTheme
!==
colorMode
)
{
window
.
localStorage
.
setItem
(
'
graphiql:theme
'
,
colorMode
);
setShow
(
false
);
}
}
},
[
colorMode
]);
return
(
<
Page
>
<
Head
><
title
>
Graph Page
</
title
></
Head
>
{
show
&&
<
GraphQL
key=
{
colorMode
}
/>
}
</
Page
>
);
};
export
default
GraphQL
Page
;
export
default
Apps
Page
;
export
{
getServerSideProps
}
from
'
lib/next/getServerSideProps
'
;
ui/graphQL/GraphQL.tsx
View file @
ba833859
...
...
@@ -4,14 +4,31 @@ import { GraphiQL } from 'graphiql';
import
React
from
'
react
'
;
import
'
graphiql/graphiql.css
'
;
const
graphQLStyle
=
{
'
.graphiql-container
'
:
{
backgroundColor
:
'
unset
'
,
},
};
const
GraphQL
=
()
=>
{
const
initialQuery
=
`{
transaction(
hash: "0x69e3923eef50eada197c3336d546936d0c994211492c9f947a24c02827568f9f"
) {
hash
blockNumber
value
gasUsed
}
}`
;
const
fetcher
=
createGraphiQLFetcher
({
url
:
'
https://base-goerli.blockscout.com/graphiql
'
,
});
return
(
<
Box
h=
"100vh"
sx=
{
{}
}
>
<
GraphiQL
fetcher=
{
fetcher
}
/>
<
Box
h=
"100vh"
sx=
{
graphQLStyle
}
>
<
GraphiQL
fetcher=
{
fetcher
}
defaultQuery=
{
initialQuery
}
/>
</
Box
>
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment