Skip to content

Commit

Permalink
chore: move data-access to oeth/shared, update clients
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Sep 5, 2023
1 parent 9a3cdd0 commit 3f3544a
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 125 deletions.
1 change: 1 addition & 0 deletions apps/oeth/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
interface ImportMetaEnv {
readonly VITE_WALLET_CONNECT_PROJECT_ID: string;
readonly VITE_ALCHEMY_ID: string;
readonly VITE_SUBSQUID_URL: string;
}

interface ImportMeta {
Expand Down
12 changes: 4 additions & 8 deletions apps/ousd/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
CssBaseline,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material';
import { queryClient } from '@origin/shared/data-access';
import { theme } from '@origin/shared/theme';
import { QueryClientProvider } from '@tanstack/react-query';
import { IntlProvider } from 'react-intl';

import { OUSDRoot } from './components';
Expand All @@ -19,12 +17,10 @@ const root = ReactDOM.createRoot(
root.render(
<StrictMode>
<IntlProvider messages={en} locale="en" defaultLocale="en">
<QueryClientProvider client={queryClient}>
<CssVarsProvider theme={theme} defaultMode="dark">
<CssBaseline />
<OUSDRoot />
</CssVarsProvider>
</QueryClientProvider>
<CssVarsProvider theme={theme} defaultMode="dark">
<CssBaseline />
<OUSDRoot />
</CssVarsProvider>
</IntlProvider>
</StrictMode>,
);
4 changes: 2 additions & 2 deletions libs/oeth/history/src/queries.generated.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { graphqlClient } from '@origin/shared/data-access';
import { graphqlClient } from '@origin/oeth/shared';
import { useQuery } from '@tanstack/react-query';

import type * as Types from '@origin/shared/data-access';
import type * as Types from '@origin/oeth/shared';
import type { UseQueryOptions } from '@tanstack/react-query';
export type DummyQueryVariables = Types.Exact<{ [key: string]: never }>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
generates: {
'libs/shared/data-access/src/generated/graphql.ts': {
'libs/oeth/shared/src/generated/graphql.ts': {
schema: process.env.VITE_SUBSQUID_URL,
documents: ['**/src/**/*.graphql'],
plugins: ['typescript'],
},
'.': {
'libs/oeth/': {
schema: process.env.VITE_SUBSQUID_URL,
documents: ['**/src/**/*.graphql'],
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.tsx',
baseTypesPath: '~@origin/shared/data-access',
baseTypesPath: '~@origin/oeth/shared',
},
hooks: { afterOneFileWrite: ['prettier --write', 'eslint --fix'] },
plugins: ['typescript-operations', 'typescript-react-query'],
config: {
fetcher: {
func: '@origin/shared/data-access#graphqlClient',
func: '@origin/oeth/shared#graphqlClient',
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions libs/oeth/shared/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"projectType": "library",
"tags": [],
"targets": {
"codegen-graphql": {
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm graphql-codegen --config 'libs/oeth/shared/codegen.ts'"
]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import axios from 'axios';

export const axiosInstance = axios.create({
baseURL: 'https://squid.subsquid.io/origin-squid/v/v4',
baseURL: import.meta.env.VITE_SUBSQUID_URL,
});

export const graphqlClient =
<_, TVariables>(query: string, variables?: TVariables) =>
<TData, TVariables>(query: string, variables?: TVariables) =>
async () => {
const res = await axiosInstance({
const res = await axiosInstance<TData>({
url: '/graphql',
method: 'POST',
headers: {
Expand All @@ -17,5 +17,5 @@ export const graphqlClient =
data: { query, variables },
});

return res.data['errors']?.[0] || res.data['data'];
return res.data['data'];
};
1 change: 1 addition & 0 deletions libs/oeth/shared/src/clients/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './graphql';
export * from './reactQuery';
export * from './wagmi';
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion libs/oeth/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './ApyHeader';
export * from './components/ApyHeader';
export * from './clients';
export * from './generated/graphql';
1 change: 1 addition & 0 deletions libs/oeth/shared/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"files": [
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../../node_modules/@nx/react/typings/image.d.ts",
"../../../libs/shared/theme/src/theme.d.ts",
"../../../apps/oeth/src/env.d.ts",
],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
Expand Down
12 changes: 0 additions & 12 deletions libs/shared/data-access/.babelrc

This file was deleted.

18 changes: 0 additions & 18 deletions libs/shared/data-access/.eslintrc.json

This file was deleted.

7 changes: 0 additions & 7 deletions libs/shared/data-access/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions libs/shared/data-access/project.json

This file was deleted.

2 changes: 0 additions & 2 deletions libs/shared/data-access/src/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions libs/shared/data-access/tsconfig.json

This file was deleted.

23 changes: 0 additions & 23 deletions libs/shared/data-access/tsconfig.lib.json

This file was deleted.

3 changes: 0 additions & 3 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
"@origin/shared/contracts": [
"libs/shared/contracts/src/index.ts"
],
"@origin/shared/data-access": [
"libs/shared/data-access/src/index.ts"
],
"@origin/shared/providers": [
"libs/shared/providers/src/index.ts"
],
Expand Down

0 comments on commit 3f3544a

Please sign in to comment.