-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
2,944 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ const config: StorybookConfig = { | |
} | ||
}, | ||
docs: { | ||
autodocs: true, | ||
autodocs: false, | ||
}, | ||
} | ||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { CodegenConfig } from '@graphql-codegen/cli' | ||
|
||
import { customSchemaLoader } from './scripts/customSchemaLoader' | ||
|
||
const schemaUrl = 'https://orion.gleev.xyz/graphql' | ||
|
||
const config: CodegenConfig = { | ||
overwrite: true, | ||
schema: [ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
{ | ||
[schemaUrl]: { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
loader: customSchemaLoader, | ||
}, | ||
}, | ||
], | ||
documents: ['./src/api/queries/**/*.graphql'], | ||
config: { | ||
scalars: { | ||
DateTime: 'Date', | ||
BigInt: 'string', | ||
}, | ||
preResolveTypes: true, // avoid using Pick | ||
}, | ||
generates: { | ||
'src/api/schemas/orion.json': { | ||
plugins: ['introspection'], | ||
config: { | ||
minify: true, | ||
}, | ||
}, | ||
'src/api/queries/__generated__/baseTypes.generated.ts': { | ||
hooks: { | ||
afterOneFileWrite: ['prettier --write', 'eslint --fix'], | ||
}, | ||
plugins: ['typescript'], | ||
}, | ||
'src/api/queries/__generated__/': { | ||
preset: 'near-operation-file', | ||
presetConfig: { | ||
baseTypesPath: 'baseTypes.generated.ts', | ||
folder: '__generated__', | ||
extension: '.generated.tsx', | ||
}, | ||
hooks: { | ||
afterOneFileWrite: ['prettier --write', 'eslint --fix'], | ||
}, | ||
plugins: ['typescript-operations', 'typescript-react-apollo'], | ||
}, | ||
}, | ||
} | ||
|
||
export default config |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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', | ||
}, | ||
} | ||
) | ||
|
||
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', | ||
}, | ||
} | ||
) | ||
.catch((error) => console.log(error.response.data)) | ||
const schema = buildClientSchema(schemaResponse && schemaResponse.data.data) | ||
return schema | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import axios from 'axios' | ||
|
||
export const axiosInstance = axios.create() | ||
|
||
axiosInstance.interceptors.response.use( | ||
(response) => response, | ||
(response) => { | ||
if (response.config.data) { | ||
response.errorData = JSON.stringify(response.config.data) | ||
} | ||
response.endpoint = response.config.url | ||
throw response | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.