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

updated graphql codegen script

parent 1cee84d9
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,7 @@ Install CIFTools `npm install ciftools -g`
**GraphQL schemas**
node data/rcsb-graphql/codegen.js
./node_modules/.bin/graphql-codegen -c ./data/rcsb-graphql/codegen.yml
### Other scripts
**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 or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment