@snowtop/ent 0.0.36 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -162,7 +162,6 @@ class AssocEdgeLoaderFactory {
162
162
  return this.createConfigurableLoader({}, context);
163
163
  }
164
164
  isConstructor(edgeCtr) {
165
- // not constructor
166
165
  return (edgeCtr.prototype &&
167
166
  edgeCtr.prototype.constructor &&
168
167
  edgeCtr.prototype.constructor.name.length > 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,10 +31,29 @@ function processFields(src, patternName) {
31
31
  if (patternName) {
32
32
  f.patternName = patternName;
33
33
  }
34
+ transformType(field.type);
34
35
  ret.push(f);
35
36
  }
36
37
  return ret;
37
38
  }
39
+ function transformImportType(typ) {
40
+ if (!typ.importType) {
41
+ return;
42
+ }
43
+ typ.importType = {
44
+ ...typ.importType,
45
+ // these 2 needed for forwards compatibility with new go schema
46
+ importPath: typ.importType.path,
47
+ import: typ.importType.type,
48
+ };
49
+ }
50
+ function transformType(typ) {
51
+ if (!typ) {
52
+ return;
53
+ }
54
+ transformImportType(typ);
55
+ transformType(typ.listElemType);
56
+ }
38
57
  function processEdges(src, patternName) {
39
58
  const ret = [];
40
59
  for (const edge of src) {
@@ -82,6 +82,7 @@ export declare enum DBType {
82
82
  export interface ImportType {
83
83
  path: string;
84
84
  type: string;
85
+ [x: string]: any;
85
86
  }
86
87
  declare type EnumMap = {
87
88
  [key: string]: string;
@@ -131,6 +132,7 @@ export interface FieldOptions {
131
132
  fieldEdge?: FieldEdge;
132
133
  primaryKey?: boolean;
133
134
  disableUserEditable?: boolean;
135
+ disableUserGraphQLEditable?: boolean;
134
136
  defaultValueOnCreate?(builder: Builder<Ent>, input: Data): any;
135
137
  defaultToViewerOnCreate?: boolean;
136
138
  defaultValueOnEdit?(builder: Builder<Ent>, input: Data): any;
@@ -16,6 +16,8 @@ interface queryConfig {
16
16
  callback?: (res: supertest.Response) => void;
17
17
  inlineFragmentRoot?: string;
18
18
  customHandlers?: RequestHandler[];
19
+ server?: any;
20
+ graphQLPath?: string;
19
21
  }
20
22
  export interface queryRootConfig extends queryConfig {
21
23
  root: string;
@@ -56,7 +56,7 @@ function server(config) {
56
56
  };
57
57
  return doWork();
58
58
  }));
59
- app.use("/graphql", ...handlers);
59
+ app.use(config.graphQLPath || "/graphql", ...handlers);
60
60
  return app;
61
61
  }
62
62
  function getInnerType(typ, list) {
@@ -72,14 +72,14 @@ function makeGraphQLRequest(config, query, fieldArgs) {
72
72
  let test;
73
73
  if (config.test) {
74
74
  if (typeof config.test === "function") {
75
- test = config.test(server(config));
75
+ test = config.test(config.server ? config.server : server(config));
76
76
  }
77
77
  else {
78
78
  test = config.test;
79
79
  }
80
80
  }
81
81
  else {
82
- test = (0, supertest_1.default)(server(config));
82
+ test = (0, supertest_1.default)(config.server ? config.server : server(config));
83
83
  }
84
84
  let files = new Map();
85
85
  // handle files
@@ -104,7 +104,9 @@ function makeGraphQLRequest(config, query, fieldArgs) {
104
104
  }
105
105
  });
106
106
  if (files.size) {
107
- let ret = test.post("/graphql").set(config.headers || {});
107
+ let ret = test
108
+ .post(config.graphQLPath || "/graphql")
109
+ .set(config.headers || {});
108
110
  ret.field("operations", JSON.stringify({
109
111
  query: query,
110
112
  variables: config.args,
@@ -130,7 +132,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
130
132
  return [
131
133
  test,
132
134
  test
133
- .post("/graphql")
135
+ .post(config.graphQLPath || "/graphql")
134
136
  .set(config.headers || {})
135
137
  .send({
136
138
  query: query,