@gapi/core 1.8.177 → 1.8.179

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.
@@ -21,18 +21,13 @@ let FederationController = class FederationController {
21
21
  query: appSchema.graphqlOptions.schema.getQueryType(),
22
22
  mutation: appSchema.graphqlOptions.schema.getMutationType(),
23
23
  });
24
- let replacer = tokens_1.FedarationReplacer;
25
- try {
26
- replacer = core_1.Container.get(tokens_1.GRAPHQL_FEDERATION_REPLACER);
27
- }
28
- catch (e) {
29
- console.error(e);
30
- }
31
24
  const sdl = (0, graphql_2.printSchema)(schema)
32
25
  .replace('_service: GraphqlFederation', '')
33
26
  .replace('status: StatusQueryType', '');
34
27
  return {
35
- sdl: replacer(sdl),
28
+ sdl: core_1.Container.has(tokens_1.GRAPHQL_FEDERATION_REPLACER)
29
+ ? core_1.Container.get(tokens_1.GRAPHQL_FEDERATION_REPLACER)(sdl)
30
+ : (0, tokens_1.FedarationReplacer)(sdl),
36
31
  };
37
32
  }
38
33
  };
@@ -0,0 +1 @@
1
+ export declare const GeoJSON: any;
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeoJSON = void 0;
4
+ const graphql_1 = require("graphql");
5
+ exports.GeoJSON = {
6
+ TypeEnum: new graphql_1.GraphQLEnumType({
7
+ name: 'GeoJSONType',
8
+ description: 'Enumeration of all GeoJSON object types.',
9
+ values: {
10
+ Point: { value: 'Point' },
11
+ MultiPoint: { value: 'MultiPoint' },
12
+ LineString: { value: 'LineString' },
13
+ MultiLineString: { value: 'MultiLineString' },
14
+ Polygon: { value: 'Polygon' },
15
+ MultiPolygon: { value: 'MultiPolygon' },
16
+ GeometryCollection: { value: 'GeometryCollection' },
17
+ Feature: { value: 'Feature' },
18
+ FeatureCollection: { value: 'FeatureCollection' },
19
+ },
20
+ }),
21
+ CoordinatesScalar: new graphql_1.GraphQLScalarType({
22
+ name: 'GeoJSONCoordinates',
23
+ description: 'A (multidimensional) set of coordinates following x, y, z order.',
24
+ serialize: coerceCoordinates,
25
+ parseValue: coerceCoordinates,
26
+ parseLiteral: parseCoordinates,
27
+ }),
28
+ JsonScalar: new graphql_1.GraphQLScalarType({
29
+ name: 'JSONObject',
30
+ description: 'Arbitrary JSON value',
31
+ serialize: coerceObject,
32
+ parseValue: coerceObject,
33
+ parseLiteral: parseObject,
34
+ }),
35
+ PointObject: new graphql_1.GraphQLObjectType({
36
+ name: 'GeoJSONPoint',
37
+ description: 'Object describing a single geographical point.',
38
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
39
+ fields: () => ({
40
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
41
+ crs: {
42
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
43
+ },
44
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
45
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
46
+ }),
47
+ }),
48
+ MultiPointObject: new graphql_1.GraphQLObjectType({
49
+ name: 'GeoJSONMultiPoint',
50
+ description: 'Object describing multiple geographical points.',
51
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
52
+ fields: () => ({
53
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
54
+ crs: {
55
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
56
+ },
57
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
58
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
59
+ }),
60
+ }),
61
+ LineStringObject: new graphql_1.GraphQLObjectType({
62
+ name: 'GeoJSONLineString',
63
+ description: 'Object describing a single connected sequence of geographical points.',
64
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
65
+ fields: () => ({
66
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
67
+ crs: {
68
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
69
+ },
70
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
71
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
72
+ }),
73
+ }),
74
+ MultiLineStringObject: new graphql_1.GraphQLObjectType({
75
+ name: 'GeoJSONMultiLineString',
76
+ description: 'Object describing multiple connected sequences of geographical points.',
77
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
78
+ fields: () => ({
79
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
80
+ crs: {
81
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
82
+ },
83
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
84
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
85
+ }),
86
+ }),
87
+ PolygonObject: new graphql_1.GraphQLObjectType({
88
+ name: 'GeoJSONPolygon',
89
+ description: 'Object describing a single shape formed by a set of geographical points.',
90
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
91
+ fields: () => ({
92
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
93
+ crs: {
94
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
95
+ },
96
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
97
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
98
+ }),
99
+ }),
100
+ MultiPolygonObject: new graphql_1.GraphQLObjectType({
101
+ name: 'GeoJSONMultiPolygon',
102
+ description: 'Object describing multiple shapes formed by sets of geographical points.',
103
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface, exports.GeoJSON.GeometryInterface],
104
+ fields: () => ({
105
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
106
+ crs: {
107
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
108
+ },
109
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
110
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
111
+ }),
112
+ }),
113
+ GeometryCollectionObject: new graphql_1.GraphQLObjectType({
114
+ name: 'GeoJSONGeometryCollection',
115
+ description: 'A set of multiple geometries, possibly of various types.',
116
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface],
117
+ fields: () => ({
118
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
119
+ crs: {
120
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
121
+ },
122
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
123
+ geometries: {
124
+ type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GeoJSON.GeometryInterface))),
125
+ },
126
+ }),
127
+ }),
128
+ FeatureObject: new graphql_1.GraphQLObjectType({
129
+ name: 'GeoJSONFeature',
130
+ description: 'An object that links a geometry to properties in order to provide context.',
131
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface],
132
+ fields: () => ({
133
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
134
+ crs: {
135
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
136
+ },
137
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
138
+ geometry: { type: exports.GeoJSON.GeometryInterface },
139
+ properties: { type: exports.GeoJSON.JsonScalar },
140
+ id: { type: graphql_1.GraphQLString },
141
+ }),
142
+ }),
143
+ FeatureCollectionObject: new graphql_1.GraphQLObjectType({
144
+ name: 'GeoJSONFeatureCollection',
145
+ description: 'A set of multiple features.',
146
+ interfaces: () => [exports.GeoJSON.GeoJSONInterface],
147
+ fields: () => ({
148
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
149
+ crs: {
150
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
151
+ },
152
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
153
+ features: {
154
+ type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GeoJSON.FeatureObject))),
155
+ },
156
+ }),
157
+ }),
158
+ CRSTypeEnum: new graphql_1.GraphQLEnumType({
159
+ name: 'GeoJSONCRSType',
160
+ description: 'Enumeration of all GeoJSON CRS object types.',
161
+ values: {
162
+ name: { value: 'name' },
163
+ link: { value: 'link' },
164
+ },
165
+ }),
166
+ NamedCRSPropertiesObject: new graphql_1.GraphQLObjectType({
167
+ name: 'GeoJSONNamedCRSProperties',
168
+ description: 'Properties for name based CRS object.',
169
+ fields: () => ({
170
+ name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
171
+ }),
172
+ }),
173
+ LinkedCRSPropertiesObject: new graphql_1.GraphQLObjectType({
174
+ name: 'GeoJSONLinkedCRSProperties',
175
+ description: 'Properties for link based CRS object.',
176
+ fields: () => ({
177
+ href: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
178
+ type: { type: graphql_1.GraphQLString },
179
+ }),
180
+ }),
181
+ CRSPropertiesUnion: new graphql_1.GraphQLUnionType({
182
+ name: 'GeoJSONCRSProperties',
183
+ description: 'CRS object properties.',
184
+ types: () => [
185
+ exports.GeoJSON.NamedCRSPropertiesObject,
186
+ exports.GeoJSON.LinkedCRSPropertiesObject,
187
+ ],
188
+ resolveType: (value) => {
189
+ if (value.name)
190
+ return exports.GeoJSON.NamedCRSPropertiesObject;
191
+ if (value.href)
192
+ return exports.GeoJSON.LinkedCRSPropertiesObject;
193
+ },
194
+ }),
195
+ CoordinateReferenceSystemObject: new graphql_1.GraphQLObjectType({
196
+ name: 'GeoJSONCoordinateReferenceSystem',
197
+ description: 'Coordinate Reference System (CRS) object.',
198
+ fields: () => ({
199
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CRSTypeEnum) },
200
+ properties: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CRSPropertiesUnion) },
201
+ }),
202
+ }),
203
+ GeoJSONInterface: new graphql_1.GraphQLInterfaceType({
204
+ name: 'GeoJSONInterface',
205
+ fields: () => ({
206
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
207
+ crs: {
208
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
209
+ },
210
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
211
+ }),
212
+ resolveType: (value) => exports.GeoJSON[`${value.type}Object`],
213
+ }),
214
+ GeometryInterface: new graphql_1.GraphQLInterfaceType({
215
+ name: 'GeoJSONGeometryInterface',
216
+ fields: () => ({
217
+ type: { type: new graphql_1.GraphQLNonNull(exports.GeoJSON.TypeEnum) },
218
+ crs: {
219
+ type: new graphql_1.GraphQLNonNull(exports.GeoJSON.CoordinateReferenceSystemObject),
220
+ },
221
+ bbox: { type: new graphql_1.GraphQLList(graphql_1.GraphQLFloat) },
222
+ coordinates: { type: exports.GeoJSON.CoordinatesScalar },
223
+ }),
224
+ resolveType: (value) => exports.GeoJSON[`${value.type}Object`],
225
+ }),
226
+ };
227
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
228
+ function coerceCoordinates(value) {
229
+ return value;
230
+ }
231
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
+ function parseCoordinates(valueAST) {
233
+ return valueAST.value;
234
+ }
235
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
236
+ function coerceObject(value) {
237
+ return JSON.parse(value);
238
+ }
239
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
240
+ function parseObject(valueAST) {
241
+ return JSON.stringify(valueAST.value);
242
+ }
package/dist/index.d.ts CHANGED
@@ -1,18 +1,10 @@
1
- import { DaemonConfig } from '@gapi/daemon';
2
1
  import { ModuleWithServices } from '@rxdi/core';
3
- import { GRAPHQL_PLUGIN_CONFIG } from '@rxdi/graphql';
4
- import { GRAPHQL_PUB_SUB_DI_CONFIG } from '@rxdi/graphql-pubsub';
5
- import { HapiConfigModel } from '@rxdi/hapi';
6
- export interface CoreModuleConfig {
7
- server?: HapiConfigModel;
8
- graphql?: GRAPHQL_PLUGIN_CONFIG;
9
- pubsub?: GRAPHQL_PUB_SUB_DI_CONFIG;
10
- daemon?: DaemonConfig;
11
- }
2
+ import { CoreModuleConfig } from './tokens';
12
3
  export declare class CoreModule {
13
4
  static forRoot(config?: CoreModuleConfig): ModuleWithServices;
14
5
  }
15
6
  export * from './enum-to-gql';
7
+ export { GeoJSON } from './geojson.types';
16
8
  export * from '@rxdi/core';
17
9
  export * from '@rxdi/graphql';
18
10
  export * from '@rxdi/graphql-pubsub';
@@ -20,6 +12,4 @@ export { withFilter } from '@rxdi/graphql-rabbitmq-subscriptions';
20
12
  export * from '@rxdi/hapi';
21
13
  export * from 'graphql';
22
14
  export { buildSchema, ExecutionResult, extendSchema, isSpecifiedScalarType, } from 'graphql';
23
- export * from 'graphql-geojson';
24
15
  export { FilterFn, PubSubEngine, PubSubOptions, ResolverFn, } from 'graphql-subscriptions';
25
- export * from 'graphql-tools';
package/dist/index.js CHANGED
@@ -21,44 +21,23 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  };
22
22
  var CoreModule_1;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.PubSubEngine = exports.isSpecifiedScalarType = exports.extendSchema = exports.buildSchema = exports.withFilter = exports.CoreModule = void 0;
24
+ exports.PubSubEngine = exports.isSpecifiedScalarType = exports.extendSchema = exports.buildSchema = exports.withFilter = exports.GeoJSON = exports.CoreModule = void 0;
25
25
  const daemon_1 = require("@gapi/daemon");
26
26
  const core_1 = require("@rxdi/core");
27
27
  const graphql_1 = require("@rxdi/graphql");
28
28
  const graphql_pubsub_1 = require("@rxdi/graphql-pubsub");
29
29
  const hapi_1 = require("@rxdi/hapi");
30
30
  const federation_controller_1 = require("./federation.controller");
31
- const DEFAULT_CONFIG = {
32
- server: {
33
- hapi: {
34
- port: 9000,
35
- },
36
- },
37
- graphql: {
38
- path: '/graphql',
39
- initQuery: true,
40
- writeEffects: false,
41
- watcherPort: '',
42
- graphqlOptions: {
43
- schema: null,
44
- },
45
- altair: {
46
- enabled: true,
47
- },
48
- },
49
- daemon: {
50
- activated: false,
51
- },
52
- };
31
+ const tokens_1 = require("./tokens");
53
32
  let CoreModule = CoreModule_1 = class CoreModule {
54
33
  static forRoot(config) {
55
- config = config || DEFAULT_CONFIG;
34
+ config = config || tokens_1.DEFAULT_CONFIG;
56
35
  return {
57
36
  module: CoreModule_1,
58
37
  controllers: [federation_controller_1.FederationController],
59
38
  frameworkImports: [
60
- hapi_1.HapiModule.forRoot(Object.assign(Object.assign({}, DEFAULT_CONFIG.server), config.server)),
61
- graphql_1.GraphQLModule.forRoot(Object.assign(Object.assign({}, DEFAULT_CONFIG.graphql), config.graphql)),
39
+ hapi_1.HapiModule.forRoot(Object.assign(Object.assign({}, tokens_1.DEFAULT_CONFIG.server), config.server)),
40
+ graphql_1.GraphQLModule.forRoot(Object.assign(Object.assign({}, tokens_1.DEFAULT_CONFIG.graphql), config.graphql)),
62
41
  graphql_pubsub_1.GraphQLPubSubModule.forRoot(config.pubsub),
63
42
  daemon_1.DaemonModule.forRoot(config.daemon),
64
43
  ],
@@ -70,6 +49,8 @@ exports.CoreModule = CoreModule = CoreModule_1 = __decorate([
70
49
  (0, core_1.Module)()
71
50
  ], CoreModule);
72
51
  __exportStar(require("./enum-to-gql"), exports);
52
+ var geojson_types_1 = require("./geojson.types");
53
+ Object.defineProperty(exports, "GeoJSON", { enumerable: true, get: function () { return geojson_types_1.GeoJSON; } });
73
54
  __exportStar(require("@rxdi/core"), exports);
74
55
  __exportStar(require("@rxdi/graphql"), exports);
75
56
  __exportStar(require("@rxdi/graphql-pubsub"), exports);
@@ -81,7 +62,5 @@ var graphql_2 = require("graphql");
81
62
  Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return graphql_2.buildSchema; } });
82
63
  Object.defineProperty(exports, "extendSchema", { enumerable: true, get: function () { return graphql_2.extendSchema; } });
83
64
  Object.defineProperty(exports, "isSpecifiedScalarType", { enumerable: true, get: function () { return graphql_2.isSpecifiedScalarType; } });
84
- __exportStar(require("graphql-geojson"), exports);
85
65
  var graphql_subscriptions_1 = require("graphql-subscriptions");
86
66
  Object.defineProperty(exports, "PubSubEngine", { enumerable: true, get: function () { return graphql_subscriptions_1.PubSubEngine; } });
87
- __exportStar(require("graphql-tools"), exports);
package/dist/tokens.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ import { DaemonConfig } from '@gapi/daemon';
1
2
  import { InjectionToken } from '@rxdi/core';
3
+ import { GRAPHQL_PLUGIN_CONFIG } from '@rxdi/graphql';
4
+ import { GRAPHQL_PUB_SUB_DI_CONFIG } from '@rxdi/graphql-pubsub';
5
+ import { HapiConfigModel } from '@rxdi/hapi';
2
6
  export declare const FedarationReplacer: (v: string) => string;
3
7
  export declare const GRAPHQL_FEDERATION_REPLACER: InjectionToken<(v: string) => string>;
8
+ export interface CoreModuleConfig {
9
+ server?: HapiConfigModel;
10
+ graphql?: GRAPHQL_PLUGIN_CONFIG;
11
+ pubsub?: GRAPHQL_PUB_SUB_DI_CONFIG;
12
+ daemon?: DaemonConfig;
13
+ }
14
+ export declare const DEFAULT_CONFIG: CoreModuleConfig;
package/dist/tokens.js CHANGED
@@ -1,7 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GRAPHQL_FEDERATION_REPLACER = exports.FedarationReplacer = void 0;
3
+ exports.DEFAULT_CONFIG = exports.GRAPHQL_FEDERATION_REPLACER = exports.FedarationReplacer = void 0;
4
4
  const core_1 = require("@rxdi/core");
5
5
  const FedarationReplacer = (v) => v;
6
6
  exports.FedarationReplacer = FedarationReplacer;
7
7
  exports.GRAPHQL_FEDERATION_REPLACER = new core_1.InjectionToken('GRAPHQL_FEDERATION_REPLACER');
8
+ exports.DEFAULT_CONFIG = {
9
+ server: {
10
+ hapi: {
11
+ port: 9000,
12
+ },
13
+ },
14
+ graphql: {
15
+ path: '/graphql',
16
+ initQuery: true,
17
+ writeEffects: false,
18
+ watcherPort: '',
19
+ graphqlOptions: {
20
+ schema: null,
21
+ },
22
+ altair: {
23
+ enabled: true,
24
+ },
25
+ },
26
+ daemon: {
27
+ activated: false,
28
+ },
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/core",
3
- "version": "1.8.177",
3
+ "version": "1.8.179",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
@@ -25,14 +25,12 @@
25
25
  "url": "https://github.com/Stradivario/gapi/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@gapi/daemon": "^1.8.176",
28
+ "@gapi/daemon": "^1.8.178",
29
29
  "@rxdi/core": "^0.7.200",
30
30
  "@rxdi/graphql": "^0.7.200",
31
31
  "@rxdi/graphql-pubsub": "^0.7.200",
32
32
  "@rxdi/hapi": "^0.7.200",
33
- "graphql": "^16.12.0",
34
- "graphql-geojson": "^1.0.0",
35
- "graphql-tools": "^5.0.0"
33
+ "graphql": "^16.12.0"
36
34
  },
37
35
  "main": "./dist/index.js",
38
36
  "types": "./dist/index.d.ts",
@@ -27,17 +27,13 @@ export class FederationController {
27
27
  query: appSchema.graphqlOptions.schema.getQueryType(),
28
28
  mutation: appSchema.graphqlOptions.schema.getMutationType(),
29
29
  });
30
- let replacer = FedarationReplacer;
31
- try {
32
- replacer = Container.get(GRAPHQL_FEDERATION_REPLACER);
33
- } catch (e) {
34
- console.error(e);
35
- }
36
30
  const sdl = printSchema(schema)
37
31
  .replace('_service: GraphqlFederation', '')
38
32
  .replace('status: StatusQueryType', '');
39
33
  return {
40
- sdl: replacer(sdl),
34
+ sdl: Container.has(GRAPHQL_FEDERATION_REPLACER)
35
+ ? Container.get(GRAPHQL_FEDERATION_REPLACER)(sdl)
36
+ : FedarationReplacer(sdl),
41
37
  };
42
38
  }
43
39
  }
@@ -0,0 +1,278 @@
1
+ import {
2
+ GraphQLEnumType,
3
+ GraphQLFloat,
4
+ GraphQLInterfaceType,
5
+ GraphQLList,
6
+ GraphQLNonNull,
7
+ GraphQLObjectType,
8
+ GraphQLScalarType,
9
+ GraphQLString,
10
+ GraphQLUnionType,
11
+ } from 'graphql';
12
+
13
+ export const GeoJSON = {
14
+ TypeEnum: new GraphQLEnumType({
15
+ name: 'GeoJSONType',
16
+ description: 'Enumeration of all GeoJSON object types.',
17
+ values: {
18
+ Point: { value: 'Point' },
19
+ MultiPoint: { value: 'MultiPoint' },
20
+ LineString: { value: 'LineString' },
21
+ MultiLineString: { value: 'MultiLineString' },
22
+ Polygon: { value: 'Polygon' },
23
+ MultiPolygon: { value: 'MultiPolygon' },
24
+ GeometryCollection: { value: 'GeometryCollection' },
25
+ Feature: { value: 'Feature' },
26
+ FeatureCollection: { value: 'FeatureCollection' },
27
+ },
28
+ }),
29
+
30
+ CoordinatesScalar: new GraphQLScalarType({
31
+ name: 'GeoJSONCoordinates',
32
+ description:
33
+ 'A (multidimensional) set of coordinates following x, y, z order.',
34
+ serialize: coerceCoordinates,
35
+ parseValue: coerceCoordinates,
36
+ parseLiteral: parseCoordinates,
37
+ }),
38
+
39
+ JsonScalar: new GraphQLScalarType({
40
+ name: 'JSONObject',
41
+ description: 'Arbitrary JSON value',
42
+ serialize: coerceObject,
43
+ parseValue: coerceObject,
44
+ parseLiteral: parseObject,
45
+ }),
46
+
47
+ PointObject: new GraphQLObjectType({
48
+ name: 'GeoJSONPoint',
49
+ description: 'Object describing a single geographical point.',
50
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
51
+ fields: () => ({
52
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
53
+ crs: {
54
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
55
+ },
56
+ bbox: { type: new GraphQLList(GraphQLFloat) },
57
+ coordinates: { type: GeoJSON.CoordinatesScalar },
58
+ }),
59
+ }),
60
+
61
+ MultiPointObject: new GraphQLObjectType({
62
+ name: 'GeoJSONMultiPoint',
63
+ description: 'Object describing multiple geographical points.',
64
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
65
+ fields: () => ({
66
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
67
+ crs: {
68
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
69
+ },
70
+ bbox: { type: new GraphQLList(GraphQLFloat) },
71
+ coordinates: { type: GeoJSON.CoordinatesScalar },
72
+ }),
73
+ }),
74
+
75
+ LineStringObject: new GraphQLObjectType({
76
+ name: 'GeoJSONLineString',
77
+ description:
78
+ 'Object describing a single connected sequence of geographical points.',
79
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
80
+ fields: () => ({
81
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
82
+ crs: {
83
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
84
+ },
85
+ bbox: { type: new GraphQLList(GraphQLFloat) },
86
+ coordinates: { type: GeoJSON.CoordinatesScalar },
87
+ }),
88
+ }),
89
+
90
+ MultiLineStringObject: new GraphQLObjectType({
91
+ name: 'GeoJSONMultiLineString',
92
+ description:
93
+ 'Object describing multiple connected sequences of geographical points.',
94
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
95
+ fields: () => ({
96
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
97
+ crs: {
98
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
99
+ },
100
+ bbox: { type: new GraphQLList(GraphQLFloat) },
101
+ coordinates: { type: GeoJSON.CoordinatesScalar },
102
+ }),
103
+ }),
104
+
105
+ PolygonObject: new GraphQLObjectType({
106
+ name: 'GeoJSONPolygon',
107
+ description:
108
+ 'Object describing a single shape formed by a set of geographical points.',
109
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
110
+ fields: () => ({
111
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
112
+ crs: {
113
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
114
+ },
115
+ bbox: { type: new GraphQLList(GraphQLFloat) },
116
+ coordinates: { type: GeoJSON.CoordinatesScalar },
117
+ }),
118
+ }),
119
+
120
+ MultiPolygonObject: new GraphQLObjectType({
121
+ name: 'GeoJSONMultiPolygon',
122
+ description:
123
+ 'Object describing multiple shapes formed by sets of geographical points.',
124
+ interfaces: () => [GeoJSON.GeoJSONInterface, GeoJSON.GeometryInterface],
125
+ fields: () => ({
126
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
127
+ crs: {
128
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
129
+ },
130
+ bbox: { type: new GraphQLList(GraphQLFloat) },
131
+ coordinates: { type: GeoJSON.CoordinatesScalar },
132
+ }),
133
+ }),
134
+
135
+ GeometryCollectionObject: new GraphQLObjectType({
136
+ name: 'GeoJSONGeometryCollection',
137
+ description: 'A set of multiple geometries, possibly of various types.',
138
+ interfaces: () => [GeoJSON.GeoJSONInterface],
139
+ fields: () => ({
140
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
141
+ crs: {
142
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
143
+ },
144
+ bbox: { type: new GraphQLList(GraphQLFloat) },
145
+ geometries: {
146
+ type: new GraphQLNonNull(
147
+ new GraphQLList(new GraphQLNonNull(GeoJSON.GeometryInterface)),
148
+ ),
149
+ },
150
+ }),
151
+ }),
152
+
153
+ FeatureObject: new GraphQLObjectType({
154
+ name: 'GeoJSONFeature',
155
+ description:
156
+ 'An object that links a geometry to properties in order to provide context.',
157
+ interfaces: () => [GeoJSON.GeoJSONInterface],
158
+ fields: () => ({
159
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
160
+ crs: {
161
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
162
+ },
163
+ bbox: { type: new GraphQLList(GraphQLFloat) },
164
+ geometry: { type: GeoJSON.GeometryInterface },
165
+ properties: { type: GeoJSON.JsonScalar },
166
+ id: { type: GraphQLString },
167
+ }),
168
+ }),
169
+
170
+ FeatureCollectionObject: new GraphQLObjectType({
171
+ name: 'GeoJSONFeatureCollection',
172
+ description: 'A set of multiple features.',
173
+ interfaces: () => [GeoJSON.GeoJSONInterface],
174
+ fields: () => ({
175
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
176
+ crs: {
177
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
178
+ },
179
+ bbox: { type: new GraphQLList(GraphQLFloat) },
180
+ features: {
181
+ type: new GraphQLNonNull(
182
+ new GraphQLList(new GraphQLNonNull(GeoJSON.FeatureObject)),
183
+ ),
184
+ },
185
+ }),
186
+ }),
187
+
188
+ CRSTypeEnum: new GraphQLEnumType({
189
+ name: 'GeoJSONCRSType',
190
+ description: 'Enumeration of all GeoJSON CRS object types.',
191
+ values: {
192
+ name: { value: 'name' },
193
+ link: { value: 'link' },
194
+ },
195
+ }),
196
+
197
+ NamedCRSPropertiesObject: new GraphQLObjectType({
198
+ name: 'GeoJSONNamedCRSProperties',
199
+ description: 'Properties for name based CRS object.',
200
+ fields: () => ({
201
+ name: { type: new GraphQLNonNull(GraphQLString) },
202
+ }),
203
+ }),
204
+
205
+ LinkedCRSPropertiesObject: new GraphQLObjectType({
206
+ name: 'GeoJSONLinkedCRSProperties',
207
+ description: 'Properties for link based CRS object.',
208
+ fields: () => ({
209
+ href: { type: new GraphQLNonNull(GraphQLString) },
210
+ type: { type: GraphQLString },
211
+ }),
212
+ }),
213
+
214
+ CRSPropertiesUnion: new GraphQLUnionType({
215
+ name: 'GeoJSONCRSProperties',
216
+ description: 'CRS object properties.',
217
+ types: () => [
218
+ GeoJSON.NamedCRSPropertiesObject,
219
+ GeoJSON.LinkedCRSPropertiesObject,
220
+ ],
221
+ resolveType: (value) => {
222
+ if (value.name) return GeoJSON.NamedCRSPropertiesObject;
223
+ if (value.href) return GeoJSON.LinkedCRSPropertiesObject;
224
+ },
225
+ }),
226
+
227
+ CoordinateReferenceSystemObject: new GraphQLObjectType({
228
+ name: 'GeoJSONCoordinateReferenceSystem',
229
+ description: 'Coordinate Reference System (CRS) object.',
230
+ fields: () => ({
231
+ type: { type: new GraphQLNonNull(GeoJSON.CRSTypeEnum) },
232
+ properties: { type: new GraphQLNonNull(GeoJSON.CRSPropertiesUnion) },
233
+ }),
234
+ }),
235
+
236
+ GeoJSONInterface: new GraphQLInterfaceType({
237
+ name: 'GeoJSONInterface',
238
+ fields: () => ({
239
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
240
+ crs: {
241
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
242
+ },
243
+ bbox: { type: new GraphQLList(GraphQLFloat) },
244
+ }),
245
+ resolveType: (value) => GeoJSON[`${value.type}Object`],
246
+ }),
247
+
248
+ GeometryInterface: new GraphQLInterfaceType({
249
+ name: 'GeoJSONGeometryInterface',
250
+ fields: () => ({
251
+ type: { type: new GraphQLNonNull(GeoJSON.TypeEnum) },
252
+ crs: {
253
+ type: new GraphQLNonNull(GeoJSON.CoordinateReferenceSystemObject),
254
+ },
255
+ bbox: { type: new GraphQLList(GraphQLFloat) },
256
+ coordinates: { type: GeoJSON.CoordinatesScalar },
257
+ }),
258
+ resolveType: (value) => GeoJSON[`${value.type}Object`],
259
+ }),
260
+ };
261
+
262
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
+ function coerceCoordinates(value: any) {
264
+ return value;
265
+ }
266
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
+ function parseCoordinates(valueAST: any) {
268
+ return valueAST.value;
269
+ }
270
+
271
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
272
+ function coerceObject(value: any) {
273
+ return JSON.parse(value);
274
+ }
275
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
+ function parseObject(valueAST: any) {
277
+ return JSON.stringify(valueAST.value);
278
+ }
package/src/index.ts CHANGED
@@ -1,43 +1,11 @@
1
- import { DaemonConfig, DaemonModule } from '@gapi/daemon';
1
+ import { DaemonModule } from '@gapi/daemon';
2
2
  import { Module, ModuleWithServices } from '@rxdi/core';
3
- import { GRAPHQL_PLUGIN_CONFIG, GraphQLModule } from '@rxdi/graphql';
4
- import {
5
- GRAPHQL_PUB_SUB_DI_CONFIG,
6
- GraphQLPubSubModule,
7
- } from '@rxdi/graphql-pubsub';
8
- import { HapiConfigModel, HapiModule } from '@rxdi/hapi';
3
+ import { GraphQLModule } from '@rxdi/graphql';
4
+ import { GraphQLPubSubModule } from '@rxdi/graphql-pubsub';
5
+ import { HapiModule } from '@rxdi/hapi';
9
6
 
10
7
  import { FederationController } from './federation.controller';
11
-
12
- export interface CoreModuleConfig {
13
- server?: HapiConfigModel;
14
- graphql?: GRAPHQL_PLUGIN_CONFIG;
15
- pubsub?: GRAPHQL_PUB_SUB_DI_CONFIG;
16
- daemon?: DaemonConfig;
17
- }
18
-
19
- const DEFAULT_CONFIG: CoreModuleConfig = {
20
- server: {
21
- hapi: {
22
- port: 9000,
23
- },
24
- },
25
- graphql: {
26
- path: '/graphql',
27
- initQuery: true,
28
- writeEffects: false,
29
- watcherPort: '',
30
- graphqlOptions: {
31
- schema: null,
32
- },
33
- altair: {
34
- enabled: true,
35
- },
36
- },
37
- daemon: {
38
- activated: false,
39
- },
40
- };
8
+ import { CoreModuleConfig, DEFAULT_CONFIG } from './tokens';
41
9
 
42
10
  @Module()
43
11
  export class CoreModule {
@@ -57,6 +25,7 @@ export class CoreModule {
57
25
  }
58
26
 
59
27
  export * from './enum-to-gql';
28
+ export { GeoJSON } from './geojson.types';
60
29
  export * from '@rxdi/core';
61
30
  export * from '@rxdi/graphql';
62
31
  export * from '@rxdi/graphql-pubsub';
@@ -69,11 +38,9 @@ export {
69
38
  extendSchema,
70
39
  isSpecifiedScalarType,
71
40
  } from 'graphql';
72
- export * from 'graphql-geojson';
73
41
  export {
74
42
  FilterFn,
75
43
  PubSubEngine,
76
44
  PubSubOptions,
77
45
  ResolverFn,
78
46
  } from 'graphql-subscriptions';
79
- export * from 'graphql-tools';
package/src/tokens.ts CHANGED
@@ -1,6 +1,40 @@
1
+ import { DaemonConfig } from '@gapi/daemon';
1
2
  import { InjectionToken } from '@rxdi/core';
3
+ import { GRAPHQL_PLUGIN_CONFIG } from '@rxdi/graphql';
4
+ import { GRAPHQL_PUB_SUB_DI_CONFIG } from '@rxdi/graphql-pubsub';
5
+ import { HapiConfigModel } from '@rxdi/hapi';
2
6
 
3
7
  export const FedarationReplacer = (v: string) => v;
4
8
  export const GRAPHQL_FEDERATION_REPLACER = new InjectionToken<
5
9
  typeof FedarationReplacer
6
10
  >('GRAPHQL_FEDERATION_REPLACER');
11
+
12
+ export interface CoreModuleConfig {
13
+ server?: HapiConfigModel;
14
+ graphql?: GRAPHQL_PLUGIN_CONFIG;
15
+ pubsub?: GRAPHQL_PUB_SUB_DI_CONFIG;
16
+ daemon?: DaemonConfig;
17
+ }
18
+
19
+ export const DEFAULT_CONFIG: CoreModuleConfig = {
20
+ server: {
21
+ hapi: {
22
+ port: 9000,
23
+ },
24
+ },
25
+ graphql: {
26
+ path: '/graphql',
27
+ initQuery: true,
28
+ writeEffects: false,
29
+ watcherPort: '',
30
+ graphqlOptions: {
31
+ schema: null,
32
+ },
33
+ altair: {
34
+ enabled: true,
35
+ },
36
+ },
37
+ daemon: {
38
+ activated: false,
39
+ },
40
+ };