@teambit/graphql 0.0.881 → 0.0.882

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.
@@ -1,134 +1,95 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.GraphqlUI = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _react() {
23
17
  const data = _interopRequireDefault(require("react"));
24
-
25
18
  _react = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _ui() {
33
24
  const data = require("@teambit/ui");
34
-
35
25
  _ui = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  function _client() {
43
31
  const data = require("@apollo/client");
44
-
45
32
  _client = function () {
46
33
  return data;
47
34
  };
48
-
49
35
  return data;
50
36
  }
51
-
52
37
  function _ws() {
53
38
  const data = require("@apollo/client/link/ws");
54
-
55
39
  _ws = function () {
56
40
  return data;
57
41
  };
58
-
59
42
  return data;
60
43
  }
61
-
62
44
  function _error() {
63
45
  const data = require("@apollo/client/link/error");
64
-
65
46
  _error = function () {
66
47
  return data;
67
48
  };
68
-
69
49
  return data;
70
50
  }
71
-
72
51
  function _crossFetch() {
73
52
  const data = _interopRequireDefault(require("cross-fetch"));
74
-
75
53
  _crossFetch = function () {
76
54
  return data;
77
55
  };
78
-
79
56
  return data;
80
57
  }
81
-
82
58
  function _createLink() {
83
59
  const data = require("./create-link");
84
-
85
60
  _createLink = function () {
86
61
  return data;
87
62
  };
88
-
89
63
  return data;
90
64
  }
91
-
92
65
  function _graphqlProvider() {
93
66
  const data = require("./graphql-provider");
94
-
95
67
  _graphqlProvider = function () {
96
68
  return data;
97
69
  };
98
-
99
70
  return data;
100
71
  }
101
-
102
72
  function _graphql() {
103
73
  const data = require("./graphql.aspect");
104
-
105
74
  _graphql = function () {
106
75
  return data;
107
76
  };
108
-
109
77
  return data;
110
78
  }
111
-
112
79
  function _renderLifecycle() {
113
80
  const data = require("./render-lifecycle");
114
-
115
81
  _renderLifecycle = function () {
116
82
  return data;
117
83
  };
118
-
119
84
  return data;
120
85
  }
121
-
122
86
  function _logging() {
123
87
  const data = require("./logging");
124
-
125
88
  _logging = function () {
126
89
  return data;
127
90
  };
128
-
129
91
  return data;
130
92
  }
131
-
132
93
  class GraphqlUI {
133
94
  constructor() {
134
95
  (0, _defineProperty2().default)(this, "getProvider", ({
@@ -141,7 +102,6 @@ class GraphqlUI {
141
102
  });
142
103
  (0, _defineProperty2().default)(this, "renderPlugins", new (_renderLifecycle().GraphqlRenderPlugins)(this));
143
104
  }
144
-
145
105
  createClient(uri, {
146
106
  state,
147
107
  subscriptionUri
@@ -156,7 +116,6 @@ class GraphqlUI {
156
116
  });
157
117
  return client;
158
118
  }
159
-
160
119
  createSsrClient({
161
120
  serverUrl,
162
121
  headers
@@ -167,7 +126,6 @@ class GraphqlUI {
167
126
  headers,
168
127
  fetch: _crossFetch().default
169
128
  })]);
170
-
171
129
  const client = new (_client().ApolloClient)({
172
130
  ssrMode: true,
173
131
  link,
@@ -175,7 +133,6 @@ class GraphqlUI {
175
133
  });
176
134
  return client;
177
135
  }
178
-
179
136
  createCache({
180
137
  state
181
138
  } = {}) {
@@ -183,7 +140,6 @@ class GraphqlUI {
183
140
  if (state) cache.restore(state);
184
141
  return cache;
185
142
  }
186
-
187
143
  createLink(uri, {
188
144
  subscriptionUri
189
145
  } = {}) {
@@ -201,23 +157,20 @@ class GraphqlUI {
201
157
  const errorLogger = (0, _error().onError)(_logging().logError);
202
158
  return _client().ApolloLink.from([errorLogger, hybridLink]);
203
159
  }
160
+
204
161
  /**
205
162
  * get the graphQL provider
206
163
  */
207
164
 
208
-
209
165
  static async provider() {
210
166
  const graphqlUI = new GraphqlUI();
211
167
  return graphqlUI;
212
168
  }
213
-
214
169
  }
215
-
216
170
  exports.GraphqlUI = GraphqlUI;
217
171
  (0, _defineProperty2().default)(GraphqlUI, "runtime", _ui().UIRuntime);
218
172
  (0, _defineProperty2().default)(GraphqlUI, "dependencies", []);
219
173
  (0, _defineProperty2().default)(GraphqlUI, "slots", []);
220
-
221
174
  _graphql().GraphqlAspect.addRuntime(GraphqlUI);
222
175
 
223
176
  //# sourceMappingURL=graphql.ui.runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GraphqlUI","client","children","GraphqlRenderPlugins","createClient","uri","state","subscriptionUri","ApolloClient","link","createLink","cache","createCache","createSsrClient","serverUrl","headers","ApolloLink","from","onError","logError","createHttpLink","credentials","fetch","crossFetch","ssrMode","InMemoryCache","restore","httpLink","HttpLink","subsLink","WebSocketLink","options","reconnect","undefined","hybridLink","createSplitLink","errorLogger","provider","graphqlUI","UIRuntime","GraphqlAspect","addRuntime"],"sources":["graphql.ui.runtime.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { UIRuntime } from '@teambit/ui';\n\nimport { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client';\nimport type { NormalizedCacheObject } from '@apollo/client';\nimport { WebSocketLink } from '@apollo/client/link/ws';\nimport { onError } from '@apollo/client/link/error';\n\nimport crossFetch from 'cross-fetch';\n\nimport { createSplitLink } from './create-link';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { GraphqlRenderPlugins } from './render-lifecycle';\nimport { logError } from './logging';\n\n/**\n * Type of gql client.\n * Used to abstract Apollo client, so consumers could import the type from graphql.ui, and not have to depend on @apollo/client directly\n * */\nexport type GraphQLClient<T> = ApolloClient<T>;\n\ntype ClientOptions = {\n /** Preset in-memory cache with state (e.g. continue state from SSR) */\n state?: NormalizedCacheObject;\n /** endpoint for websocket connections */\n subscriptionUri?: string;\n};\n\nexport class GraphqlUI {\n createClient(uri: string, { state, subscriptionUri }: ClientOptions = {}) {\n const client = new ApolloClient({\n link: this.createLink(uri, { subscriptionUri }),\n cache: this.createCache({ state }),\n });\n\n return client;\n }\n\n createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {\n const link = ApolloLink.from([\n onError(logError),\n createHttpLink({\n credentials: 'include',\n uri: serverUrl,\n headers,\n fetch: crossFetch,\n }),\n ]);\n\n const client = new ApolloClient({\n ssrMode: true,\n link,\n cache: this.createCache(),\n });\n\n return client;\n }\n\n private createCache({ state }: { state?: NormalizedCacheObject } = {}) {\n const cache = new InMemoryCache();\n\n if (state) cache.restore(state);\n\n return cache;\n }\n\n private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n const httpLink = new HttpLink({ credentials: 'include', uri });\n const subsLink = subscriptionUri\n ? new WebSocketLink({\n uri: subscriptionUri,\n options: { reconnect: true },\n })\n : undefined;\n\n const hybridLink = subsLink ? createSplitLink(httpLink, subsLink) : httpLink;\n const errorLogger = onError(logError);\n\n return ApolloLink.from([errorLogger, hybridLink]);\n }\n\n /**\n * get the graphQL provider\n */\n getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n };\n\n readonly renderPlugins = new GraphqlRenderPlugins(this);\n\n static runtime = UIRuntime;\n static dependencies = [];\n static slots = [];\n\n static async provider() {\n const graphqlUI = new GraphqlUI();\n\n return graphqlUI;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;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scriptionUri","ApolloClient","link","createLink","cache","createCache","createSsrClient","serverUrl","headers","ApolloLink","from","onError","logError","createHttpLink","credentials","fetch","crossFetch","ssrMode","InMemoryCache","restore","httpLink","HttpLink","subsLink","WebSocketLink","options","reconnect","undefined","hybridLink","createSplitLink","errorLogger","provider","graphqlUI","UIRuntime","GraphqlAspect","addRuntime"],"sources":["graphql.ui.runtime.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { UIRuntime } from '@teambit/ui';\n\nimport { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client';\nimport type { NormalizedCacheObject } from '@apollo/client';\nimport { WebSocketLink } from '@apollo/client/link/ws';\nimport { onError } from '@apollo/client/link/error';\n\nimport crossFetch from 'cross-fetch';\n\nimport { createSplitLink } from './create-link';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { GraphqlRenderPlugins } from './render-lifecycle';\nimport { logError } from './logging';\n\n/**\n * Type of gql client.\n * Used to abstract Apollo client, so consumers could import the type from graphql.ui, and not have to depend on @apollo/client directly\n * */\nexport type GraphQLClient<T> = ApolloClient<T>;\n\ntype ClientOptions = {\n /** Preset in-memory cache with state (e.g. continue state from SSR) */\n state?: NormalizedCacheObject;\n /** endpoint for websocket connections */\n subscriptionUri?: string;\n};\n\nexport class GraphqlUI {\n createClient(uri: string, { state, subscriptionUri }: ClientOptions = {}) {\n const client = new ApolloClient({\n link: this.createLink(uri, { subscriptionUri }),\n cache: this.createCache({ state }),\n });\n\n return client;\n }\n\n createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {\n const link = ApolloLink.from([\n onError(logError),\n createHttpLink({\n credentials: 'include',\n uri: serverUrl,\n headers,\n fetch: crossFetch,\n }),\n ]);\n\n const client = new ApolloClient({\n ssrMode: true,\n link,\n cache: this.createCache(),\n });\n\n return client;\n }\n\n private createCache({ state }: { state?: NormalizedCacheObject } = {}) {\n const cache = new InMemoryCache();\n\n if (state) cache.restore(state);\n\n return cache;\n }\n\n private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n const httpLink = new HttpLink({ credentials: 'include', uri });\n const subsLink = subscriptionUri\n ? new WebSocketLink({\n uri: subscriptionUri,\n options: { reconnect: true },\n })\n : undefined;\n\n const hybridLink = subsLink ? createSplitLink(httpLink, subsLink) : httpLink;\n const errorLogger = onError(logError);\n\n return ApolloLink.from([errorLogger, hybridLink]);\n }\n\n /**\n * get the graphQL provider\n */\n getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n };\n\n readonly renderPlugins = new GraphqlRenderPlugins(this);\n\n static runtime = UIRuntime;\n static dependencies = [];\n static slots = [];\n\n static async provider() {\n const graphqlUI = new GraphqlUI();\n\n return graphqlUI;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlUI);\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAeO,MAAMA,SAAS,CAAC;EAAA;IAAA,qDAwDP,CAAC;MAAEC,MAAM;MAAEC;IAA8D,CAAC,KAAK;MAC3F,oBAAO,+BAAC,kCAAe;QAAC,MAAM,EAAED;MAAO,GAAEC,QAAQ,CAAmB;IACtE,CAAC;IAAA,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GtB,eAAe,GAC5B,KAAIuB,mBAAa,EAAC;MAChBzB,GAAG,EAAEE,eAAe;MACpBwB,OAAO,EAAE;QAAEC,SAAS,EAAE;MAAK;IAC7B,CAAC,CAAC,GACFC,SAAS;IAEb,MAAMC,UAAU,GAAGL,QAAQ,GAAG,IAAAM,6BAAe,EAACR,QAAQ,EAAEE,QAAQ,CAAC,GAAGF,QAAQ;IAC5E,MAAMS,WAAW,GAAG,IAAAlB,gBAAO,EAACC,mBAAQ,CAAC;IAErC,OAAOH,oBAAU,CAACC,IAAI,CAAC,CAACmB,WAAW,EAAEF,UAAU,CAAC,CAAC;EACnD;;EAEA;AACF;AACA;;EAWE,aAAaG,QAAQ,GAAG;IACtB,MAAMC,SAAS,GAAG,IAAItC,SAAS,EAAE;IAEjC,OAAOsC,SAAS;EAClB;AACF;AAAC;AAAA,gCAvEYtC,SAAS,aA8DHuC,eAAS;AAAA,gCA9DfvC,SAAS,kBA+DE,EAAE;AAAA,gCA/DbA,SAAS,WAgEL,EAAE;AASnBwC,wBAAa,CAACC,UAAU,CAACzC,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -27,34 +27,25 @@ Object.defineProperty(exports, "default", {
27
27
  return _graphql().GraphqlAspect;
28
28
  }
29
29
  });
30
-
31
30
  function _graphql() {
32
31
  const data = require("./graphql.aspect");
33
-
34
32
  _graphql = function () {
35
33
  return data;
36
34
  };
37
-
38
35
  return data;
39
36
  }
40
-
41
37
  function _graphqlProvider() {
42
38
  const data = require("./graphql-provider");
43
-
44
39
  _graphqlProvider = function () {
45
40
  return data;
46
41
  };
47
-
48
42
  return data;
49
43
  }
50
-
51
44
  function _graphqlError() {
52
45
  const data = require("./graphql-error");
53
-
54
46
  _graphqlError = function () {
55
47
  return data;
56
48
  };
57
-
58
49
  return data;
59
50
  }
60
51
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { GraphqlAspect, GraphqlAspect as default } from './graphql.aspect';\n\nexport type { Schema } from './schema';\nexport type { GraphqlMain, SchemaSlot } from './graphql.main.runtime';\nexport type { GraphqlUI, GraphQLClient } from './graphql.ui.runtime';\nexport type { GraphQLServer } from './graphql-server';\nexport { GraphQLProvider } from './graphql-provider';\nexport { GraphQlError } from './graphql-error';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { GraphqlAspect, GraphqlAspect as default } from './graphql.aspect';\n\nexport type { Schema } from './schema';\nexport type { GraphqlMain, SchemaSlot } from './graphql.main.runtime';\nexport type { GraphqlUI, GraphQLClient } from './graphql.ui.runtime';\nexport type { GraphQLServer } from './graphql-server';\nexport { GraphQLProvider } from './graphql-provider';\nexport { GraphQlError } from './graphql-error';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
package/dist/logging.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.logError = logError;
7
-
8
7
  function logError({
9
8
  graphQLErrors,
10
9
  networkError,
@@ -14,15 +13,20 @@ function logError({
14
13
  message,
15
14
  locations,
16
15
  path
17
- }) => // eslint-disable-next-line no-console
18
- console.error(`[gql] error on "${operation.operationName}" - "${message}"`, locations, path)); // eslint-disable-next-line no-console
16
+ }) =>
17
+ // eslint-disable-next-line no-console
18
+ console.error(`[gql] error on "${operation.operationName}" - "${message}"`, locations, path));
19
19
 
20
+ // eslint-disable-next-line no-console
20
21
  if (networkError) console.error('[gql] network error', `"${operation.operationName}"`, networkError);
21
- } // // // a fetch monkey patch with logs. useful to debug gql
22
+ }
23
+
24
+ // // // a fetch monkey patch with logs. useful to debug gql
22
25
  // function loggingCrossFetch(...p: Parameters<typeof fetch>) {
23
26
  // const [url, init] = p;
24
27
  // const headers = init?.headers;
25
28
  // const body = init?.body;
29
+
26
30
  // console.debug('[gql]', 'fetching', url, body, { headers });
27
31
  // const promise = crossFetch(...p);
28
32
  // promise
@@ -1 +1 @@
1
- {"version":3,"names":["logError","graphQLErrors","networkError","operation","forEach","message","locations","path","console","error","operationName"],"sources":["logging.ts"],"sourcesContent":["import { ErrorResponse } from '@apollo/client/link/error';\n\nexport function logError({ graphQLErrors, networkError, operation }: ErrorResponse) {\n if (graphQLErrors)\n graphQLErrors.forEach(({ message, locations, path }) =>\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"${operation.operationName}\" - \"${message}\"`, locations, path)\n );\n\n // eslint-disable-next-line no-console\n if (networkError) console.error('[gql] network error', `\"${operation.operationName}\"`, networkError);\n}\n\n// // // a fetch monkey patch with logs. useful to debug gql\n// function loggingCrossFetch(...p: Parameters<typeof fetch>) {\n// const [url, init] = p;\n// const headers = init?.headers;\n// const body = init?.body;\n\n// console.debug('[gql]', 'fetching', url, body, { headers });\n// const promise = crossFetch(...p);\n// promise\n// .then((result) => console.debug('[gql]', 'finished', result))\n// .catch((err) => console.debug('[gql]', 'error', err));\n// return promise;\n// }\n"],"mappings":";;;;;;;AAEO,SAASA,QAAT,CAAkB;EAAEC,aAAF;EAAiBC,YAAjB;EAA+BC;AAA/B,CAAlB,EAA6E;EAClF,IAAIF,aAAJ,EACEA,aAAa,CAACG,OAAd,CAAsB,CAAC;IAAEC,OAAF;IAAWC,SAAX;IAAsBC;EAAtB,CAAD,KACpB;EACAC,OAAO,CAACC,KAAR,CAAe,mBAAkBN,SAAS,CAACO,aAAc,QAAOL,OAAQ,GAAxE,EAA4EC,SAA5E,EAAuFC,IAAvF,CAFF,EAFgF,CAOlF;;EACA,IAAIL,YAAJ,EAAkBM,OAAO,CAACC,KAAR,CAAc,qBAAd,EAAsC,IAAGN,SAAS,CAACO,aAAc,GAAjE,EAAqER,YAArE;AACnB,C,CAED;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"names":["logError","graphQLErrors","networkError","operation","forEach","message","locations","path","console","error","operationName"],"sources":["logging.ts"],"sourcesContent":["import { ErrorResponse } from '@apollo/client/link/error';\n\nexport function logError({ graphQLErrors, networkError, operation }: ErrorResponse) {\n if (graphQLErrors)\n graphQLErrors.forEach(({ message, locations, path }) =>\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"${operation.operationName}\" - \"${message}\"`, locations, path)\n );\n\n // eslint-disable-next-line no-console\n if (networkError) console.error('[gql] network error', `\"${operation.operationName}\"`, networkError);\n}\n\n// // // a fetch monkey patch with logs. useful to debug gql\n// function loggingCrossFetch(...p: Parameters<typeof fetch>) {\n// const [url, init] = p;\n// const headers = init?.headers;\n// const body = init?.body;\n\n// console.debug('[gql]', 'fetching', url, body, { headers });\n// const promise = crossFetch(...p);\n// promise\n// .then((result) => console.debug('[gql]', 'finished', result))\n// .catch((err) => console.debug('[gql]', 'error', err));\n// return promise;\n// }\n"],"mappings":";;;;;;AAEO,SAASA,QAAQ,CAAC;EAAEC,aAAa;EAAEC,YAAY;EAAEC;AAAyB,CAAC,EAAE;EAClF,IAAIF,aAAa,EACfA,aAAa,CAACG,OAAO,CAAC,CAAC;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAK,CAAC;EACjD;EACAC,OAAO,CAACC,KAAK,CAAE,mBAAkBN,SAAS,CAACO,aAAc,QAAOL,OAAQ,GAAE,EAAEC,SAAS,EAAEC,IAAI,CAAC,CAC7F;;EAEH;EACA,IAAIL,YAAY,EAAEM,OAAO,CAACC,KAAK,CAAC,qBAAqB,EAAG,IAAGN,SAAS,CAACO,aAAc,GAAE,EAAER,YAAY,CAAC;AACtG;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,99 +1,72 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.GraphqlRenderPlugins = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _react() {
23
17
  const data = _interopRequireDefault(require("react"));
24
-
25
18
  _react = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _ssr() {
33
24
  const data = require("@apollo/client/react/ssr");
34
-
35
25
  _ssr = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  function _server() {
43
31
  const data = _interopRequireDefault(require("react-dom/server"));
44
-
45
32
  _server = function () {
46
33
  return data;
47
34
  };
48
-
49
35
  return data;
50
36
  }
51
-
52
37
  function _lodash() {
53
38
  const data = _interopRequireDefault(require("lodash.pick"));
54
-
55
39
  _lodash = function () {
56
40
  return data;
57
41
  };
58
-
59
42
  return data;
60
43
  }
61
-
62
44
  function _uiFoundationUi() {
63
45
  const data = require("@teambit/ui-foundation.ui.is-browser");
64
-
65
46
  _uiFoundationUi = function () {
66
47
  return data;
67
48
  };
68
-
69
49
  return data;
70
50
  }
71
-
72
51
  function _graphqlProvider() {
73
52
  const data = require("./graphql-provider");
74
-
75
53
  _graphqlProvider = function () {
76
54
  return data;
77
55
  };
78
-
79
56
  return data;
80
57
  }
81
-
82
58
  function _graphql() {
83
59
  const data = require("./graphql.aspect");
84
-
85
60
  _graphql = function () {
86
61
  return data;
87
62
  };
88
-
89
63
  return data;
90
64
  }
91
-
92
65
  // Calling getMarkupFromTree instead of getDataFromTree so we can control the render function
93
66
  // This is required since upgrade to @apollo/client v3.6.9 because otherwise the ssr is not working since
94
67
  // webpack is not bundling the react-dom/server
95
- const ALLOWED_HEADERS = ['cookie'];
96
68
 
69
+ const ALLOWED_HEADERS = ['cookie'];
97
70
  class GraphqlRenderPlugins {
98
71
  constructor(graphqlUI) {
99
72
  this.graphqlUI = graphqlUI;
@@ -130,14 +103,12 @@ class GraphqlRenderPlugins {
130
103
  state: undefined
131
104
  };
132
105
  let state;
133
-
134
106
  try {
135
107
  state = JSON.parse(raw);
136
108
  } catch (e) {
137
109
  // eslint-disable-next-line no-console
138
110
  console.error('[GraphQL] failed deserializing state from DOM', e);
139
111
  }
140
-
141
112
  return {
142
113
  state
143
114
  };
@@ -171,16 +142,12 @@ class GraphqlRenderPlugins {
171
142
  });
172
143
  (0, _defineProperty2().default)(this, "reactContext", _uiFoundationUi().isBrowser ? this.BrowserGqlProvider : ServerGqlProvider);
173
144
  }
174
-
175
145
  getClient() {
176
146
  if (!this._client) return this.browserInit().client;
177
147
  return this._client;
178
148
  }
179
-
180
149
  }
181
-
182
150
  exports.GraphqlRenderPlugins = GraphqlRenderPlugins;
183
-
184
151
  function ServerGqlProvider({
185
152
  renderCtx,
186
153
  children
@@ -1 +1 @@
1
- {"version":3,"names":["ALLOWED_HEADERS","GraphqlRenderPlugins","constructor","graphqlUI","GraphqlAspect","id","browser","port","location","serverUrl","client","createSsrClient","headers","pick","ctx","app","getMarkupFromTree","tree","renderFunction","ReactDOMServer","renderToStaticMarkup","undefined","json","JSON","stringify","extract","raw","state","parse","e","console","error","window","isInsecure","protocol","wsUrl","host","createClient","subscriptionUri","_client","renderCtx","children","TypeError","isBrowser","BrowserGqlProvider","ServerGqlProvider","getClient","browserInit"],"sources":["render-lifecycle.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n// Calling getMarkupFromTree instead of getDataFromTree so we can control the render function\n// This is required since upgrade to @apollo/client v3.6.9 because otherwise the ssr is not working since\n// webpack is not bundling the react-dom/server\nimport { getMarkupFromTree } from '@apollo/client/react/ssr';\nimport ReactDOMServer from 'react-dom/server';\nimport type { ApolloClient, NormalizedCacheObject } from '@apollo/client';\nimport pick from 'lodash.pick';\n\nimport { isBrowser } from '@teambit/ui-foundation.ui.is-browser';\nimport type { SSR } from '@teambit/ui';\n\nimport type { GraphqlUI, GraphQLClient } from './graphql.ui.runtime';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\n\ntype RenderContext = {\n client: GraphQLClient<any>;\n};\n\nconst ALLOWED_HEADERS = ['cookie'];\n\nexport class GraphqlRenderPlugins implements SSR.RenderPlugin<RenderContext, { state?: NormalizedCacheObject }> {\n constructor(private graphqlUI: GraphqlUI) {}\n\n key = GraphqlAspect.id;\n\n serverInit = ({ browser }: SSR.SsrSession) => {\n const port = browser?.location.port || 3000;\n const serverUrl = `http://localhost:${port}/graphql`;\n\n const client = this.graphqlUI.createSsrClient({\n serverUrl,\n headers: pick(browser?.headers, ALLOWED_HEADERS),\n });\n\n const ctx: RenderContext = { client };\n return ctx;\n };\n\n /**\n * Eagerly and recursively execute all gql queries in the app.\n * Data will be available in gqlClient.extract()\n */\n onBeforeRender = async (ctx: RenderContext, app: ReactNode) => {\n await getMarkupFromTree({ tree: app, renderFunction: ReactDOMServer.renderToStaticMarkup });\n };\n\n serialize = (ctx?: RenderContext) => {\n const client = ctx?.client;\n if (!client) return undefined;\n\n return {\n json: JSON.stringify(client.extract()),\n };\n };\n\n deserialize = (raw?: string) => {\n if (!raw) return { state: undefined };\n let state: NormalizedCacheObject | undefined;\n try {\n state = JSON.parse(raw);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('[GraphQL] failed deserializing state from DOM', e);\n }\n\n return { state };\n };\n\n private _client: ApolloClient<NormalizedCacheObject> | undefined = undefined;\n\n browserInit = ({ state }: { state?: NormalizedCacheObject } = {}) => {\n const { location } = window;\n const isInsecure = location.protocol === 'http:';\n const wsUrl = `${isInsecure ? 'ws:' : 'wss:'}//${location.host}/subscriptions`;\n\n const client = this.graphqlUI.createClient('/graphql', { state, subscriptionUri: wsUrl });\n this._client = client;\n\n return { client };\n };\n\n getClient() {\n if (!this._client) return this.browserInit().client;\n return this._client;\n }\n\n private BrowserGqlProvider = ({ renderCtx, children }: { renderCtx?: RenderContext; children: ReactNode }) => {\n if (!renderCtx?.client) throw new TypeError('GQL client is not initialized, make sure `.browserInit()` executes');\n\n return <this.graphqlUI.getProvider client={renderCtx?.client}>{children}</this.graphqlUI.getProvider>;\n };\n\n reactContext = isBrowser ? this.BrowserGqlProvider : ServerGqlProvider;\n}\n\nfunction ServerGqlProvider({ renderCtx, children }: { renderCtx?: RenderContext; children: ReactNode }) {\n if (!renderCtx?.client)\n throw new TypeError('GQL client has not been initialized during SSR, make sure `.serverInit()` executes');\n\n const { client } = renderCtx;\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAbA;AACA;AACA;AAiBA,MAAMA,eAAe,GAAG,CAAC,QAAD,CAAxB;;AAEO,MAAMC,oBAAN,CAAyG;EAC9GC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,6CAEpCC,wBAAA,CAAcC,EAFsB;IAAA,oDAI7B,CAAC;MAAEC;IAAF,CAAD,KAAiC;MAC5C,MAAMC,IAAI,GAAG,CAAAD,OA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B,MAAM,EAAE9B;EAAzB,GAAkC+B,QAAlC,CAAP;AACD"}
1
+ {"version":3,"names":["ALLOWED_HEADERS","GraphqlRenderPlugins","constructor","graphqlUI","GraphqlAspect","id","browser","port","location","serverUrl","client","createSsrClient","headers","pick","ctx","app","getMarkupFromTree","tree","renderFunction","ReactDOMServer","renderToStaticMarkup","undefined","json","JSON","stringify","extract","raw","state","parse","e","console","error","window","isInsecure","protocol","wsUrl","host","createClient","subscriptionUri","_client","renderCtx","children","TypeError","isBrowser","BrowserGqlProvider","ServerGqlProvider","getClient","browserInit"],"sources":["render-lifecycle.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n// Calling getMarkupFromTree instead of getDataFromTree so we can control the render function\n// This is required since upgrade to @apollo/client v3.6.9 because otherwise the ssr is not working since\n// webpack is not bundling the react-dom/server\nimport { getMarkupFromTree } from '@apollo/client/react/ssr';\nimport ReactDOMServer from 'react-dom/server';\nimport type { ApolloClient, NormalizedCacheObject } from '@apollo/client';\nimport pick from 'lodash.pick';\n\nimport { isBrowser } from '@teambit/ui-foundation.ui.is-browser';\nimport type { SSR } from '@teambit/ui';\n\nimport type { GraphqlUI, GraphQLClient } from './graphql.ui.runtime';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\n\ntype RenderContext = {\n client: GraphQLClient<any>;\n};\n\nconst ALLOWED_HEADERS = ['cookie'];\n\nexport class GraphqlRenderPlugins implements SSR.RenderPlugin<RenderContext, { state?: NormalizedCacheObject }> {\n constructor(private graphqlUI: GraphqlUI) {}\n\n key = GraphqlAspect.id;\n\n serverInit = ({ browser }: SSR.SsrSession) => {\n const port = browser?.location.port || 3000;\n const serverUrl = `http://localhost:${port}/graphql`;\n\n const client = this.graphqlUI.createSsrClient({\n serverUrl,\n headers: pick(browser?.headers, ALLOWED_HEADERS),\n });\n\n const ctx: RenderContext = { client };\n return ctx;\n };\n\n /**\n * Eagerly and recursively execute all gql queries in the app.\n * Data will be available in gqlClient.extract()\n */\n onBeforeRender = async (ctx: RenderContext, app: ReactNode) => {\n await getMarkupFromTree({ tree: app, renderFunction: ReactDOMServer.renderToStaticMarkup });\n };\n\n serialize = (ctx?: RenderContext) => {\n const client = ctx?.client;\n if (!client) return undefined;\n\n return {\n json: JSON.stringify(client.extract()),\n };\n };\n\n deserialize = (raw?: string) => {\n if (!raw) return { state: undefined };\n let state: NormalizedCacheObject | undefined;\n try {\n state = JSON.parse(raw);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('[GraphQL] failed deserializing state from DOM', e);\n }\n\n return { state };\n };\n\n private _client: ApolloClient<NormalizedCacheObject> | undefined = undefined;\n\n browserInit = ({ state }: { state?: NormalizedCacheObject } = {}) => {\n const { location } = window;\n const isInsecure = location.protocol === 'http:';\n const wsUrl = `${isInsecure ? 'ws:' : 'wss:'}//${location.host}/subscriptions`;\n\n const client = this.graphqlUI.createClient('/graphql', { state, subscriptionUri: wsUrl });\n this._client = client;\n\n return { client };\n };\n\n getClient() {\n if (!this._client) return this.browserInit().client;\n return this._client;\n }\n\n private BrowserGqlProvider = ({ renderCtx, children }: { renderCtx?: RenderContext; children: ReactNode }) => {\n if (!renderCtx?.client) throw new TypeError('GQL client is not initialized, make sure `.browserInit()` executes');\n\n return <this.graphqlUI.getProvider client={renderCtx?.client}>{children}</this.graphqlUI.getProvider>;\n };\n\n reactContext = isBrowser ? this.BrowserGqlProvider : ServerGqlProvider;\n}\n\nfunction ServerGqlProvider({ renderCtx, children }: { renderCtx?: RenderContext; children: ReactNode }) {\n if (!renderCtx?.client)\n throw new TypeError('GQL client has not been initialized during SSR, make sure `.serverInit()` executes');\n\n const { client } = renderCtx;\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA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GC,iBAAiB;EAvE3B;EA4D3CC,SAAS,GAAG;IACV,IAAI,CAAC,IAAI,CAACP,OAAO,EAAE,OAAO,IAAI,CAACQ,WAAW,EAAE,CAACrC,MAAM;IACnD,OAAO,IAAI,CAAC6B,OAAO;EACrB;AASF;AAAC;AAED,SAASM,iBAAiB,CAAC;EAAEL,SAAS;EAAEC;AAA6D,CAAC,EAAE;EACtG,IAAI,EAACD,SAAS,aAATA,SAAS,eAATA,SAAS,CAAE9B,MAAM,GACpB,MAAM,IAAIgC,SAAS,CAAC,oFAAoF,CAAC;EAE3G,MAAM;IAAEhC;EAAO,CAAC,GAAG8B,SAAS;EAC5B,oBAAO,+BAAC,kCAAe;IAAC,MAAM,EAAE9B;EAAO,GAAE+B,QAAQ,CAAmB;AACtE"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/graphql",
3
- "version": "0.0.881",
3
+ "version": "0.0.882",
4
4
  "homepage": "https://bit.dev/teambit/harmony/graphql",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "graphql",
9
- "version": "0.0.881"
9
+ "version": "0.0.882"
10
10
  },
11
11
  "dependencies": {
12
12
  "@graphql-modules/core": "0.7.17",
@@ -35,7 +35,7 @@
35
35
  "@teambit/cli": "0.0.591",
36
36
  "@teambit/logger": "0.0.684",
37
37
  "@teambit/toolbox.network.get-port": "0.0.120",
38
- "@teambit/ui": "0.0.881",
38
+ "@teambit/ui": "0.0.882",
39
39
  "@teambit/ui-foundation.ui.is-browser": "0.0.492"
40
40
  },
41
41
  "devDependencies": {
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.881/dist/graphql.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.881/dist/graphql.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.882/dist/graphql.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.882/dist/graphql.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];