Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-5224 ENG-5242 feat(graphql,1ui,template): graphql package update to new schema and modified codegen #997

Merged
merged 11 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/template/app/routes/app+/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export default function Playground() {
userPosition: position
? {
shares: position.shares,
totalShares: position.vault?.totalShares,
currentSharePrice: position.vault?.currentSharePrice,
totalShares: position.vault?.total_shares,
currentSharePrice: position.vault?.current_share_price,
}
: null,
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"graphql:build": "nx build @0xintuition/graphql",
"graphql:lint": "nx lint @0xintuition/graphql",
"graphql:test": "nx test @0xintuition/graphql --reporter=verbose",
"graphql:codegen": "nx codegen @0xintuition/graphql",
"graphql:codegen:watch": "nx codegen:watch @0xintuition/graphql",
"graphql:codegen:build": "nx codegen:build @0xintuition/graphql",
"graphql:typecheck": "nx typecheck @0xintuition/graphql",
"protocol:build": "nx build @0xintuition/protocol",
"protocol:lint": "nx lint @0xintuition/protocol",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ const SmartIdentityCard = () => {
variant="non-user"
avatarSrc={atomData?.atom?.image ?? ''}
name={atomData?.atom?.label ?? ''}
value={atomData?.atom?.vault?.totalShares ?? 0}
value={atomData?.atom?.vault?.total_shares ?? 0}
currency="ETH"
walletAddress={atomData?.atom?.walletId ?? ''}
walletAddress={atomData?.atom?.wallet_id ?? ''}
/>
)
}
Expand Down
5 changes: 5 additions & 0 deletions packages/graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ You can also run this from the monorepo root:
pnpm graphql:codegen
```

### Schema Management

The package uses a local `schema.graphql` file as the source of truth for generating TypeScript types. This ensures consistent behavior across all environments and makes the package more portable for external use.

### Testing

Run unit tests with:
Expand Down Expand Up @@ -166,6 +170,7 @@ The package can be configured through the following files:
- `codegen.ts` - GraphQL code generation settings
- `tsconfig.json` - TypeScript configuration
- `vitest.config.ts` - Test configuration
- `schema.graphql` - GraphQL schema (source of truth)

## Contributing

Expand Down
17 changes: 14 additions & 3 deletions packages/graphql/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CodegenConfig } from '@graphql-codegen/cli'
import type { Types } from '@graphql-codegen/plugin-helpers'

import { API_URL_DEV } from './src/constants'

const commonGenerateOptions: Types.ConfiguredOutput = {
config: {
reactQueryVersion: 5,
Expand Down Expand Up @@ -34,9 +36,18 @@ const commonGenerateOptions: Types.ConfiguredOutput = {
const config: CodegenConfig = {
overwrite: true,
hooks: { afterAllFileWrite: ['prettier --write'] },
schema: process.env.HASURA_PROJECT_ENDPOINT
? [process.env.HASURA_PROJECT_ENDPOINT]
: ['./schema.graphql'],
// Try local schema first, fall back to remote if needed
schema: [
'./schema.graphql',
{
[API_URL_DEV]: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
},
],
ignoreNoDocuments: true,
documents: ['**/*.graphql'],
generates: {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@0xintuition/graphql",
"description": "GraphQL",
"version": "0.3.0",
"version": "0.4.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
Loading
Loading