FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
interface/src/graphql/data/fetchGraphQL.ts at main · ptrwtts/interface · GitHub
ptrwtts
/
interface
Public
forked from
Uniswap/interface
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
interface
/
src
/
graphql
/
data
/
fetchGraphQL.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (22 loc) · 707 Bytes
Breadcrumbs
interface
/
src
/
graphql
/
data
/
fetchGraphQL.ts
Copy path
File metadata and controls
28 lines (22 loc) · 707 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import
{
Variables
}
from
'react-relay'
import
{
GraphQLResponse
,
RequestParameters
}
from
'relay-runtime'
const
GRAPHQL_URL
=
process
.
env
.
REACT_APP_AWS_API_ENDPOINT
if
(
!
GRAPHQL_URL
)
{
throw
new
Error
(
'AWS URL MISSING FROM ENVIRONMENT'
)
}
const
headers
=
{
'Content-Type'
:
'application/json'
,
}
const
fetchQuery
=
(
params
:
RequestParameters
,
variables
:
Variables
)
:
Promise
<
GraphQLResponse
>
=>
{
const
body
=
JSON
.
stringify
(
{
query
:
params
.
text
,
// GraphQL text from input
variables
,
}
)
return
fetch
(
GRAPHQL_URL
,
{
method
:
'POST'
,
body
,
headers
}
)
.
then
(
(
res
)
=>
res
.
json
(
)
)
.
catch
(
(
e
)
=>
{
console
.
error
(
e
)
return
{
data
:
[
]
}
}
)
}
export
default
fetchQuery
Back
|
FazBrowse Home
|
New Git URL