Skip to content
Snippets Groups Projects
Commit 9341c19b authored by Alexander Rose's avatar Alexander Rose
Browse files

updated graphql codegen script

parent 1cee84d9
Branches
Tags
No related merge requests found
...@@ -93,7 +93,7 @@ Install CIFTools `npm install ciftools -g` ...@@ -93,7 +93,7 @@ Install CIFTools `npm install ciftools -g`
**GraphQL schemas** **GraphQL schemas**
node data/rcsb-graphql/codegen.js ./node_modules/.bin/graphql-codegen -c ./data/rcsb-graphql/codegen.yml
### Other scripts ### Other scripts
**Create chem comp bond table** **Create chem comp bond table**
......
const { generate } = require('graphql-code-generator')
const path = require('path')
const basePath = path.join(__dirname, '..', '..', 'src', 'mol-model-props', 'rcsb', 'graphql')
generate({
schema: 'http://rest-staging.rcsb.org/graphql',
documents: {
[path.join(basePath, 'symmetry.gql.ts')]: {
loader: path.join(__dirname, 'loader.js')
},
},
generates: {
[path.join(basePath, 'types.ts')]: {
plugins: ['time', 'typescript-common', 'typescript-client']
}
},
overwrite: true,
config: path.join(__dirname, 'codegen.json')
}, true).then(
() => console.log('done')
).catch(e => console.error(e))
\ No newline at end of file
{
"flattenTypes": true,
"generatorConfig": {
"immutableTypes": true
}
}
\ No newline at end of file
schema: http://data-staging.rcsb.org/graphql
documents: './src/mol-model-props/rcsb/graphql/symmetry.gql.ts'
generates:
'./src/mol-model-props/rcsb/graphql/types.d.ts':
plugins:
- add: '/* eslint-disable */'
- time
- typescript
- typescript-operations
config:
immutableTypes: true
\ No newline at end of file
const { parse } = require('graphql');
const { readFileSync } = require('fs');
module.exports = function(docString, config) {
const str = readFileSync(docString, { encoding: 'utf-8' }).trim()
.replace(/^export default `/, '')
.replace(/`$/, '')
return [
{
filePath: docString,
content: parse(str)
}
];
};
\ No newline at end of file
File suppressed by a .gitattributes entry, the file's encoding is unsupported, or the file size exceeds the limit.
...@@ -63,6 +63,13 @@ ...@@ -63,6 +63,13 @@
], ],
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@graphql-codegen/add": "^1.11.2",
"@graphql-codegen/cli": "^1.11.2",
"@graphql-codegen/time": "^1.11.2",
"@graphql-codegen/typescript": "^1.11.2",
"@graphql-codegen/typescript-graphql-files-modules": "^1.11.2",
"@graphql-codegen/typescript-graphql-request": "^1.11.2",
"@graphql-codegen/typescript-operations": "^1.11.2",
"@typescript-eslint/eslint-plugin": "^2.17.0", "@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.17.0", "@typescript-eslint/eslint-plugin-tslint": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0", "@typescript-eslint/parser": "^2.17.0",
...@@ -75,14 +82,12 @@ ...@@ -75,14 +82,12 @@
"extra-watch-webpack-plugin": "^1.0.3", "extra-watch-webpack-plugin": "^1.0.3",
"file-loader": "^5.0.2", "file-loader": "^5.0.2",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"graphql-code-generator": "^0.18.2",
"graphql-codegen-time": "^0.18.2",
"graphql-codegen-typescript-template": "^0.18.2",
"http-server": "^0.12.1", "http-server": "^0.12.1",
"jest": "^25.1.0", "jest": "^25.1.0",
"jest-raw-loader": "^1.0.1", "jest-raw-loader": "^1.0.1",
"mini-css-extract-plugin": "^0.9.0", "mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"pascal-case": "^3.1.1",
"raw-loader": "^4.0.0", "raw-loader": "^4.0.0",
"resolve-url-loader": "^3.1.1", "resolve-url-loader": "^3.1.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment