Browse Source

chore: Fix config for graphql codegen

Michael Bromley 6 years ago
parent
commit
59a8815149

+ 5 - 6
README.md

@@ -15,11 +15,10 @@ as inventory, order and customer management. The code for this is located in the
 ```
 vendure/
 ├── admin-ui/       # Source of the admin ui app (an Angular CLI project)
-├── codegen/        # Scripts used to generate TypeScript code and docs from source
 ├── docs/           # Documentation source
-├── server/         # Source for the Vendure server
-├── shared/         # Types and utils shared by the server & admin ui
-
+├── packages/       # Source for the Vendure server & plugin packages
+├── scripts/
+    ├── codegen/    # Scripts used to generate TypeScript code from the GraphQL APIs
 ```
 
 ## Development
@@ -58,8 +57,8 @@ Vendure uses [TypeORM](http://typeorm.io), so it compatible will any database wh
 [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator) is used to automatically create TypeScript interfaces
 for all GraphQL server operations and admin ui queries. These generated interfaces are used in both the admin ui and the server.
 
-Run `yarn generate-gql-types` to generate TypeScript interfaces based on these queries. The generated
-types are located at [`./shared/generated-types.ts`](./shared/generated-types.ts).
+Run `yarn codegen` to generate TypeScript interfaces based on these queries. The generated
+types are located at [`packages/common/src/generated-types.ts`](./packages/common/src/generated-types.ts) & [`packages/common/src/generated-shop-types.ts`](./packages/common/src/generated-shop-types.ts).
 
 ### Testing
 

+ 3 - 3
package.json

@@ -7,9 +7,9 @@
     "docs:watch": "concurrently -n docgen,hugo,webpack -c green,blue,cyan \"yarn generate-api-docs && yarn generate-config-docs -w\" \"cd docs && hugo server\" \"cd docs && yarn webpack -w\"",
     "docs:build": "yarn generate-api-docs && yarn generate-config-docs && cd docs && yarn webpack --prod && hugo",
     "docs:deploy": "cd docs && yarn && cd .. && yarn docs:build",
-    "generate-gql-types": "ts-node ./codegen/generate-graphql-types.ts",
-    "generate-config-docs": "ts-node ./codegen/generate-config-docs.ts",
-    "generate-api-docs": "ts-node ./codegen/generate-api-docs.ts --api=shop && ts-node ./codegen/generate-api-docs.ts --api=admin",
+    "codegen": "ts-node scripts/codegen/generate-graphql-types.ts",
+    "generate-config-docs": "ts-node scripts/generate-config-docs.ts",
+    "generate-api-docs": "ts-node scripts/generate-api-docs.ts --api=shop && ts-node scripts/generate-api-docs.ts --api=admin",
     "format": "prettier --write --html-whitespace-sensitivity ignore",
     "lint:core": "cd packages/core && yarn lint --fix",
     "lint:admin-ui": "cd admin-ui && yarn lint --fix",

+ 3 - 2
packages/common/src/generated-shop-types.ts

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-03-25T13:48:49+01:00
+// Generated in 2019-04-01T11:03:11+02:00
 export type Maybe<T> = T | null;
 
 export interface OrderListOptions {
@@ -1569,7 +1569,7 @@ export interface SearchResult {
     facetValueIds: string[];
     /** An array of ids of the Collections in which this result appears */
     collectionIds: string[];
-    /** A relevence score for the result. Differs between database implementations. */
+    /** A relevence score for the result. Differs between database implementations */
     score: number;
 }
 
@@ -1899,4 +1899,5 @@ export interface ResetPasswordMutationArgs {
 // Unions
 // ====================================================
 
+/** The price of a search result product, either as a range or as a single price */
 export type SearchResultPrice = PriceRange | SinglePrice;

+ 3 - 3
packages/common/src/generated-types.ts

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-03-25T13:48:50+01:00
+// Generated in 2019-04-01T11:03:13+02:00
 export type Maybe<T> = T | null;
 
 
@@ -5467,7 +5467,7 @@ export interface SearchResult {
   facetValueIds: string[];
   /** An array of ids of the Collections in which this result appears */
   collectionIds: string[];
-  /** A relevence score for the result. Differs between database implementations. */
+  /** A relevence score for the result. Differs between database implementations */
   score: number;
 }
 
@@ -6248,7 +6248,7 @@ export interface SetUiLanguageMutationArgs {
 // ====================================================
 
 
-
+/** The price of a search result product, either as a range or as a single price */
 export type SearchResultPrice = PriceRange | SinglePrice;
 
 

File diff suppressed because it is too large
+ 0 - 0
schema-admin.json


File diff suppressed because it is too large
+ 0 - 0
schema-shop.json


+ 2 - 2
schema.json

@@ -12409,7 +12409,7 @@
           },
           {
             "name": "score",
-            "description": "A relevence score for the result. Differs between database implementations.",
+            "description": "A relevence score for the result. Differs between database implementations",
             "args": [],
             "type": {
               "kind": "NON_NULL",
@@ -12432,7 +12432,7 @@
       {
         "kind": "UNION",
         "name": "SearchResultPrice",
-        "description": null,
+        "description": "The price of a search result product, either as a range or as a single price",
         "fields": null,
         "inputFields": null,
         "interfaces": null,

+ 2 - 2
codegen/client-schema.ts → scripts/codegen/client-schema.ts

@@ -2,8 +2,8 @@ import fs from 'fs';
 import { makeExecutableSchema } from 'graphql-tools';
 import path from 'path';
 
-const CLIENT_SCHEMA_FILE = '../admin-ui/src/app/data/client-state/client-types.graphql';
-const LANGUAGE_CODE_FILE = '../server/src/api/schema/common/language-code.graphql';
+const CLIENT_SCHEMA_FILE = '../../admin-ui/src/app/data/client-state/client-types.graphql';
+const LANGUAGE_CODE_FILE = '../../packages/core/src/api/schema/common/language-code.graphql';
 
 function loadGraphQL(file: string): string {
     const filePath = path.join(__dirname, file);

+ 1 - 1
codegen/download-introspection-schema.ts → scripts/codegen/download-introspection-schema.ts

@@ -2,7 +2,7 @@ import fs from 'fs';
 import { introspectionQuery } from 'graphql';
 import http from 'http';
 
-import { ADMIN_API_PATH, API_PORT } from '../shared/shared-constants';
+import { ADMIN_API_PATH, API_PORT } from '../../packages/common/src/shared-constants';
 
 // tslint:disable:no-console
 

+ 7 - 7
codegen/generate-graphql-types.ts → scripts/codegen/generate-graphql-types.ts

@@ -5,13 +5,13 @@ import { TypeScriptNamingConventionMap } from 'graphql-codegen-typescript-common
 import { mergeSchemas } from 'graphql-tools';
 import path from 'path';
 
-import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH } from '../shared/shared-constants';
+import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH } from '../../packages/common/src/shared-constants';
 
 import { downloadIntrospectionSchema } from './download-introspection-schema';
 
-const CLIENT_QUERY_FILES = path.join(__dirname, '../admin-ui/src/app/data/definitions/**/*.ts');
-const ADMIN_SCHEMA_OUTPUT_FILE = path.join(__dirname, '../schema-admin.json');
-const SHOP_SCHEMA_OUTPUT_FILE = path.join(__dirname, '../schema-shop.json');
+const CLIENT_QUERY_FILES = path.join(__dirname, '../../admin-ui/src/app/data/definitions/**/*.ts');
+const ADMIN_SCHEMA_OUTPUT_FILE = path.join(__dirname, '../../schema-admin.json');
+const SHOP_SCHEMA_OUTPUT_FILE = path.join(__dirname, '../../schema-shop.json');
 
 // tslint:disable:no-console
 
@@ -31,7 +31,7 @@ Promise.all([
         const combinedSchemas = mergeSchemas({ schemas: [adminSchema, shopSchema]});
 
         const combinedJson = graphqlSync(combinedSchemas, introspectionQuery).data;
-        fs.writeFileSync(path.join(__dirname, '../schema.json'), JSON.stringify(combinedJson, null, 2));
+        fs.writeFileSync(path.join(__dirname, '../../schema.json'), JSON.stringify(combinedJson, null, 2));
 
         const namingConventionConfig = {
             namingConvention: {
@@ -41,7 +41,7 @@ Promise.all([
         return generate({
             overwrite: true,
             generates: {
-                [path.join(__dirname, '../shared/generated-types.ts')]: {
+                [path.join(__dirname, '../../packages/common/src/generated-types.ts')]: {
                     schema: [ADMIN_SCHEMA_OUTPUT_FILE, path.join(__dirname, 'client-schema.ts')],
                     documents: CLIENT_QUERY_FILES,
                     plugins: [
@@ -52,7 +52,7 @@ Promise.all([
                         'typescript-server'],
                     config: namingConventionConfig,
                 },
-                [path.join(__dirname, '../shared/generated-shop-types.ts')]: {
+                [path.join(__dirname, '../../packages/common/src/generated-shop-types.ts')]: {
                     schema: [SHOP_SCHEMA_OUTPUT_FILE],
                     plugins: [
                         { add: '// tslint:disable' },

+ 0 - 0
codegen/docgen-utils.ts → scripts/docgen-utils.ts


+ 0 - 0
codegen/generate-api-docs.ts → scripts/generate-api-docs.ts


+ 0 - 0
codegen/generate-config-docs.ts → scripts/generate-config-docs.ts


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