@teambit/graphql 0.0.730 → 0.0.733
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.
- package/create-remote-schemas/create-remote-schemas.ts +13 -2
- package/dist/create-remote-schemas/create-remote-schemas.js +17 -2
- package/dist/create-remote-schemas/create-remote-schemas.js.map +1 -1
- package/package-tar/teambit-graphql-0.0.733.tgz +0 -0
- package/package.json +8 -8
- package/{preview-1652325916507.js → preview-1652757984397.js} +2 -2
- package/package-tar/teambit-graphql-0.0.730.tgz +0 -0
|
@@ -3,20 +3,31 @@ import { setContext } from 'apollo-link-context';
|
|
|
3
3
|
import { HttpLink } from 'apollo-link-http';
|
|
4
4
|
import { makeRemoteExecutableSchema, introspectSchema } from 'apollo-server';
|
|
5
5
|
import { WebSocketLink } from 'apollo-link-ws';
|
|
6
|
-
import { split } from 'apollo-link';
|
|
6
|
+
import { split, ApolloLink } from 'apollo-link';
|
|
7
7
|
import { getMainDefinition } from 'apollo-utilities';
|
|
8
8
|
import { SubscriptionClient } from 'subscriptions-transport-ws';
|
|
9
9
|
import ws from 'ws';
|
|
10
10
|
import { GraphQLServer } from '../graphql-server';
|
|
11
11
|
|
|
12
12
|
async function getRemoteSchema({ uri, subscriptionsUri }) {
|
|
13
|
+
const wrappingLink = new ApolloLink((operation, forward) => {
|
|
14
|
+
return forward(operation).map((response) => {
|
|
15
|
+
const context = operation.getContext();
|
|
16
|
+
if (context?.response?.headers?.get('set-cookie')) {
|
|
17
|
+
context?.graphqlContext?.res?.setHeader('set-cookie', context?.response?.headers?.get('set-cookie'));
|
|
18
|
+
}
|
|
19
|
+
return response;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
13
22
|
// @ts-ignore
|
|
14
23
|
const http = new HttpLink({ uri, fetch });
|
|
15
24
|
const httpLink = setContext((request, previousContext) => {
|
|
16
25
|
return {
|
|
17
26
|
headers: previousContext?.graphqlContext?.headers,
|
|
18
27
|
};
|
|
19
|
-
})
|
|
28
|
+
})
|
|
29
|
+
.concat(wrappingLink)
|
|
30
|
+
.concat(http);
|
|
20
31
|
|
|
21
32
|
if (!subscriptionsUri) {
|
|
22
33
|
return makeRemoteExecutableSchema({
|
|
@@ -105,7 +105,22 @@ async function getRemoteSchema({
|
|
|
105
105
|
uri,
|
|
106
106
|
subscriptionsUri
|
|
107
107
|
}) {
|
|
108
|
-
|
|
108
|
+
const wrappingLink = new (_apolloLink().ApolloLink)((operation, forward) => {
|
|
109
|
+
return forward(operation).map(response => {
|
|
110
|
+
var _context$response, _context$response$hea;
|
|
111
|
+
|
|
112
|
+
const context = operation.getContext();
|
|
113
|
+
|
|
114
|
+
if (context !== null && context !== void 0 && (_context$response = context.response) !== null && _context$response !== void 0 && (_context$response$hea = _context$response.headers) !== null && _context$response$hea !== void 0 && _context$response$hea.get('set-cookie')) {
|
|
115
|
+
var _context$graphqlConte, _context$graphqlConte2, _context$response2, _context$response2$he;
|
|
116
|
+
|
|
117
|
+
context === null || context === void 0 ? void 0 : (_context$graphqlConte = context.graphqlContext) === null || _context$graphqlConte === void 0 ? void 0 : (_context$graphqlConte2 = _context$graphqlConte.res) === null || _context$graphqlConte2 === void 0 ? void 0 : _context$graphqlConte2.setHeader('set-cookie', context === null || context === void 0 ? void 0 : (_context$response2 = context.response) === null || _context$response2 === void 0 ? void 0 : (_context$response2$he = _context$response2.headers) === null || _context$response2$he === void 0 ? void 0 : _context$response2$he.get('set-cookie'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return response;
|
|
121
|
+
});
|
|
122
|
+
}); // @ts-ignore
|
|
123
|
+
|
|
109
124
|
const http = new (_apolloLinkHttp().HttpLink)({
|
|
110
125
|
uri,
|
|
111
126
|
fetch: _nodeFetch().default
|
|
@@ -116,7 +131,7 @@ async function getRemoteSchema({
|
|
|
116
131
|
return {
|
|
117
132
|
headers: previousContext === null || previousContext === void 0 ? void 0 : (_previousContext$grap = previousContext.graphqlContext) === null || _previousContext$grap === void 0 ? void 0 : _previousContext$grap.headers
|
|
118
133
|
};
|
|
119
|
-
}).concat(http);
|
|
134
|
+
}).concat(wrappingLink).concat(http);
|
|
120
135
|
|
|
121
136
|
if (!subscriptionsUri) {
|
|
122
137
|
return (0, _apolloServer().makeRemoteExecutableSchema)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["create-remote-schemas.ts"],"names":["getRemoteSchema","uri","subscriptionsUri","
|
|
1
|
+
{"version":3,"sources":["create-remote-schemas.ts"],"names":["getRemoteSchema","uri","subscriptionsUri","wrappingLink","ApolloLink","operation","forward","map","response","context","getContext","headers","get","graphqlContext","res","setHeader","http","HttpLink","fetch","httpLink","request","previousContext","concat","schema","link","client","SubscriptionClient","reconnect","ws","wsLink","WebSocketLink","definition","query","kind","createRemoteSchemas","servers","schemasP","server","Promise","all"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA,eAAeA,eAAf,CAA+B;AAAEC,EAAAA,GAAF;AAAOC,EAAAA;AAAP,CAA/B,EAA0D;AACxD,QAAMC,YAAY,GAAG,KAAIC,wBAAJ,EAAe,CAACC,SAAD,EAAYC,OAAZ,KAAwB;AAC1D,WAAOA,OAAO,CAACD,SAAD,CAAP,CAAmBE,GAAnB,CAAwBC,QAAD,IAAc;AAAA;;AAC1C,YAAMC,OAAO,GAAGJ,SAAS,CAACK,UAAV,EAAhB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xD;AACA;;AACA,QAAMD,IAAI,GAAG,yBACVnB,SAAD,IAAe;AACb,UAAM0B,UAAU,GAAG,0CAAkB1B,SAAS,CAAC2B,KAA5B,CAAnB;AACA,WAAOD,UAAU,CAACE,IAAX,KAAoB,qBAApB,IAA6CF,UAAU,CAAC1B,SAAX,KAAyB,cAA7E;AACD,GAJU,EAKXwB,MALW,EAMXV,QANW,CAAb;AASA,SAAO,gDAA2B;AAChCI,IAAAA,MAAM,EAAE,MAAM,sCAAiBJ,QAAjB,CADkB;AAEhCK,IAAAA;AAFgC,GAA3B,CAAP;AAID;;AAEM,eAAeU,mBAAf,CAAmCC,OAAnC,EAA6D;AAClE,QAAMC,QAAQ,GAAGD,OAAO,CAAC5B,GAAR,CAAY,MAAO8B,MAAP,IAAkB;AAC7C,WAAOrC,eAAe,CAAC;AACrBC,MAAAA,GAAG,EAAEoC,MAAM,CAACpC,GADS;AAErBC,MAAAA,gBAAgB,EAAEmC,MAAM,CAACnC;AAFJ,KAAD,CAAtB;AAID,GALgB,CAAjB;AAOA,SAAOoC,OAAO,CAACC,GAAR,CAAYH,QAAZ,CAAP;AACD","sourcesContent":["import fetch from 'node-fetch';\nimport { setContext } from 'apollo-link-context';\nimport { HttpLink } from 'apollo-link-http';\nimport { makeRemoteExecutableSchema, introspectSchema } from 'apollo-server';\nimport { WebSocketLink } from 'apollo-link-ws';\nimport { split, ApolloLink } from 'apollo-link';\nimport { getMainDefinition } from 'apollo-utilities';\nimport { SubscriptionClient } from 'subscriptions-transport-ws';\nimport ws from 'ws';\nimport { GraphQLServer } from '../graphql-server';\n\nasync function getRemoteSchema({ uri, subscriptionsUri }) {\n const wrappingLink = new ApolloLink((operation, forward) => {\n return forward(operation).map((response) => {\n const context = operation.getContext();\n if (context?.response?.headers?.get('set-cookie')) {\n context?.graphqlContext?.res?.setHeader('set-cookie', context?.response?.headers?.get('set-cookie'));\n }\n return response;\n });\n });\n // @ts-ignore\n const http = new HttpLink({ uri, fetch });\n const httpLink = setContext((request, previousContext) => {\n return {\n headers: previousContext?.graphqlContext?.headers,\n };\n })\n .concat(wrappingLink)\n .concat(http);\n\n if (!subscriptionsUri) {\n return makeRemoteExecutableSchema({\n schema: await introspectSchema(httpLink),\n link: httpLink,\n });\n }\n\n // Create WebSocket link with custom client\n const client = new SubscriptionClient(subscriptionsUri, { reconnect: true }, ws);\n const wsLink = new WebSocketLink(client);\n\n // Using the ability to split links, we can send data to each link\n // depending on what kind of operation is being sent\n const link = split(\n (operation) => {\n const definition = getMainDefinition(operation.query);\n return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';\n },\n wsLink,\n httpLink\n );\n\n return makeRemoteExecutableSchema({\n schema: await introspectSchema(httpLink),\n link,\n });\n}\n\nexport async function createRemoteSchemas(servers: GraphQLServer[]) {\n const schemasP = servers.map(async (server) => {\n return getRemoteSchema({\n uri: server.uri,\n subscriptionsUri: server.subscriptionsUri,\n });\n });\n\n return Promise.all(schemasP);\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/graphql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.733",
|
|
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.
|
|
9
|
+
"version": "0.0.733"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-modules/core": "0.7.17",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@babel/runtime": "7.12.18",
|
|
33
33
|
"core-js": "^3.0.0",
|
|
34
34
|
"@teambit/harmony": "0.3.3",
|
|
35
|
-
"@teambit/cli": "0.0.
|
|
36
|
-
"@teambit/logger": "0.0.
|
|
35
|
+
"@teambit/cli": "0.0.490",
|
|
36
|
+
"@teambit/logger": "0.0.582",
|
|
37
37
|
"@teambit/toolbox.network.get-port": "0.0.113",
|
|
38
|
-
"@teambit/preview": "0.0.
|
|
39
|
-
"@teambit/ui": "0.0.
|
|
38
|
+
"@teambit/preview": "0.0.733",
|
|
39
|
+
"@teambit/ui": "0.0.733",
|
|
40
40
|
"@teambit/ui-foundation.ui.is-browser": "0.0.486"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@apollo/client": "^3.0.0",
|
|
56
56
|
"graphql": "14.7.0",
|
|
57
|
-
"@teambit/legacy": "1.0.
|
|
57
|
+
"@teambit/legacy": "1.0.270",
|
|
58
58
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
59
59
|
"react": "^16.8.0 || ^17.0.0"
|
|
60
60
|
},
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react": "-"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@teambit/legacy": "1.0.
|
|
87
|
+
"@teambit/legacy": "1.0.270",
|
|
88
88
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
89
89
|
"react": "^16.8.0 || ^17.0.0"
|
|
90
90
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.733/dist/graphql.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@0.0.733/dist/graphql.docs.mdx')]
|
|
Binary file
|