Browse Source

updated graphql codegen script

Alexander Rose 5 years ago
parent
commit
9341c19bd5
7 changed files with 1018 additions and 1110 deletions
  1. 1 1
      README.md
  2. 0 22
      data/rcsb-graphql/codegen.js
  3. 0 6
      data/rcsb-graphql/codegen.json
  4. 11 0
      data/rcsb-graphql/codegen.yml
  5. 0 14
      data/rcsb-graphql/loader.js
  6. 998 1064
      package-lock.json
  7. 8 3
      package.json

+ 1 - 1
README.md

@@ -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**

+ 0 - 22
data/rcsb-graphql/codegen.js

@@ -1,22 +0,0 @@
-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))

+ 0 - 6
data/rcsb-graphql/codegen.json

@@ -1,6 +0,0 @@
-{
-    "flattenTypes": true,
-    "generatorConfig": {
-        "immutableTypes": true
-    }
-}

+ 11 - 0
data/rcsb-graphql/codegen.yml

@@ -0,0 +1,11 @@
+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

+ 0 - 14
data/rcsb-graphql/loader.js

@@ -1,14 +0,0 @@
-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)
-        }
-    ];
-};

File diff suppressed because it is too large
+ 998 - 1064
package-lock.json


+ 8 - 3
package.json

@@ -63,6 +63,13 @@
   ],
   "license": "MIT",
   "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-tslint": "^2.17.0",
     "@typescript-eslint/parser": "^2.17.0",
@@ -75,14 +82,12 @@
     "extra-watch-webpack-plugin": "^1.0.3",
     "file-loader": "^5.0.2",
     "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",
     "jest": "^25.1.0",
     "jest-raw-loader": "^1.0.1",
     "mini-css-extract-plugin": "^0.9.0",
     "node-sass": "^4.13.1",
+    "pascal-case": "^3.1.1",
     "raw-loader": "^4.0.0",
     "resolve-url-loader": "^3.1.1",
     "sass-loader": "^8.0.2",

Some files were not shown because too many files changed in this diff