Skip to content

Commit

Permalink
Release v4.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
attemka authored Nov 8, 2023
2 parents ab2c138 + 27092ae commit 9a474ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
6 changes: 4 additions & 2 deletions packages/atlas/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { CodegenConfig } from '@graphql-codegen/cli'

import { customSchemaLoader } from './scripts/customSchemaLoader'

const schemaUrl = 'https://orion.gleev.xyz/graphql'
const ENV = process.env.VITE_DEFAULT_DATA_ENV?.toUpperCase() ?? process.env.VITE_ENV?.toUpperCase() ?? 'PRODUCTION'
const schemaUrl = process.env[`VITE_${ENV}_ORION_URL`]
if (!schemaUrl) throw new Error(`VITE_${ENV}_ORION_URL is not defined`)

const config: CodegenConfig = {
overwrite: true,
Expand All @@ -13,7 +15,7 @@ const config: CodegenConfig = {
[schemaUrl]: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
loader: customSchemaLoader,
loader: customSchemaLoader(schemaUrl),
},
},
],
Expand Down
60 changes: 20 additions & 40 deletions packages/atlas/scripts/customSchemaLoader.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
import axios from 'axios'
import { buildClientSchema, getIntrospectionQuery } from 'graphql'

async function fetchAuthCookie() {
const response = await axios.post(
`https://auth.gleev.xyz/api/v1/anonymous-auth`,
{},
{
method: 'POST',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
}
)
export function customSchemaLoader(schemaUrl: string) {
return async () => {
const introspectionQuery = getIntrospectionQuery()

return response.headers['set-cookie']
}

export async function customSchemaLoader() {
const authCookie = await fetchAuthCookie()
const introspectionQuery = getIntrospectionQuery()

if (!authCookie) {
throw new Error('Authorization cookie is missing.')
}

const schemaResponse = await axios
.post<any>(
'https://orion.gleev.xyz/graphql',
{
query: introspectionQuery,
},
{
method: 'post',
withCredentials: true,
headers: {
Cookie: authCookie.join('; '),
'Content-Type': 'application/json',
const schemaResponse = await axios
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.post<any>(
schemaUrl,
{
query: introspectionQuery,
},
}
)
.catch((error) => console.log(error.response.data))
const schema = buildClientSchema(schemaResponse && schemaResponse.data.data)
return schema
{
method: 'post',
withCredentials: true,
headers: { 'Content-Type': 'application/json' },
}
)
// eslint-disable-next-line no-console
.catch((error) => console.log(error.response.data))
const schema = buildClientSchema(schemaResponse && schemaResponse.data.data)
return schema
}
}
4 changes: 3 additions & 1 deletion packages/atlas/src/.env
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ VITE_NEXT_FAUCET_URL=https://atlas-next.joystream.org/member-faucet/register
VITE_NEXT_YPP_FAUCET_URL=https://52.204.147.11.nip.io/membership

# Local development env URLs
VITE_LOCAL_ORION_URL=http://localhost:6116/graphql
VITE_LOCAL_ORION_AUTH_URL=http://localhost:4074/api/v1
VITE_LOCAL_ORION_URL=http://localhost:4350/graphql
VITE_LOCAL_QUERY_NODE_SUBSCRIPTION_URL=ws://localhost:8081/graphql
VITE_LOCAL_NODE_URL=ws://localhost:9944/ws-rpc
VITE_LOCAL_FAUCET_URL=http://localhost:3002/register
VITE_LOCAL_YPP_FAUCET_URL=https://52.204.147.11.nip.io/membership

VITE_SENTRY_AUTH_TOKEN=

0 comments on commit 9a474ec

Please sign in to comment.