Skip to content

Commit

Permalink
generate schema types (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Vieira committed Mar 16, 2023
1 parent 8bbe1ea commit 30ee1b2
Show file tree
Hide file tree
Showing 8 changed files with 2,155 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
build
.bin
subgraph.yaml
addresses.ts
addresses.ts
generated-types
dist
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ $ yarn prepare:alfajores # or mainnet
$ yarn codegen
$ yarn build
$ yarn deploy:alfajores # or mainnet
```

## Generate types and pre-package
```
$ yarn types
$ yarn package
```
23 changes: 23 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
generates: {
"generated-types/index.ts": {
config: {
avoidOptionals: true,
scalars: {
BigDecimal: "string",
Bytes: "string",
},
skipTypename: true,
useTypeImports: true,
},
plugins: ["typescript"],
}
},
overwrite: true,
schema: "./schema.graphql",
};

export default config;
File renamed without changes.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "subgraph",
"license": "Apache-2.0",
"version": "1.0.0",
"files": ["dist"],
"engines": {
"node": "18.x"
},
"scripts": {
"types": "graphql-codegen --config codegen.ts",
"package": "rimraf dist && tsc -p tsconfig.package.json",
"codegen": "graph codegen",
"build": "graph build",
"test": "graph test --version 0.5.4",
Expand All @@ -31,10 +35,14 @@
},
"devDependencies": {
"@babel/core": "7.20.7",
"@graphql-codegen/cli": "3.2.2",
"@graphql-codegen/typescript": "3.0.2",
"@graphql-codegen/typescript-resolvers": "3.1.1",
"eslint": "8.30.0",
"eslint-config-impact-market": "2.0.3",
"mustache": "4.2.0",
"prettier": "2.8.1",
"rimraf": "4.4.0",
"typescript": "~4.1.6"
}
}
3 changes: 3 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
scalar Bytes
scalar BigDecimal

"""
Contributions of an asset to an entity
"""
Expand Down
30 changes: 30 additions & 0 deletions tsconfig.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedParameters": false,
"noUnusedLocals": true,
"skipLibCheck": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2017",
"module": "commonjs",
"esModuleInterop": true,
"removeComments": false,
"declaration": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"outDir": "./dist",
"lib": [
"es2017",
"esnext.asynciterable",
"dom"
],
"allowJs": true,
"strict": true,
},
"include": [
"generated-types/*.ts",
]
}

Loading

0 comments on commit 30ee1b2

Please sign in to comment.