stellate 2.11.0 → 2.12.0
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/dist/apollo-server.js +2 -2
- package/dist/apollo-server.mjs +11 -2
- package/dist/bin.js +578 -596
- package/dist/envelop.js +2 -2
- package/dist/envelop.mjs +5 -1
- package/dist/graphql-yoga.js +2 -2
- package/dist/graphql-yoga.mjs +9 -1
- package/package.json +1 -1
package/dist/apollo-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`);
|
|
1
|
+
"use strict";var q=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var n in t)q(e,n,{get:t[n],enumerable:!0})},J=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D(t))!R.call(e,r)&&r!==n&&q(e,r,{get:()=>t[r],enumerable:!(a=V(t,r))||a.enumerable});return e};var B=e=>J(q({},"__esModule",{value:!0}),e);var G={};$(G,{createBlake3Hash:()=>h,createStellateLoggerPlugin:()=>F});module.exports=B(G);function h(e){let t=0,n=e.length;if(n===0)return t;for(let a=0;a<n;++a){let r=e.charCodeAt(a);t=(t<<5)-t+r,t&=t}return t>>>0}function x({headers:e,operation:t,method:n,start:a,operationName:r,errors:S,response:p,variables:u,responseHeaders:s,sendVariablesAsHash:l,hasSetCookie:i,graphqlClientName:f,graphqlClientVersion:v}){let g=e.get("x-forwarded-for"),b=g?g.split(","):[],c=s&&s.get("vary"),m;if(c&&c.length){let d=c.split(",").map(o=>o&&o.trim()).sort().map(o=>{let y=o&&e.get(o);return y?`${o}:${y}`:void 0}).filter(Boolean).join(`
|
|
2
|
+
`);m=h(d)}return{graphqlClientName:f,graphqlClientVersion:v,operation:t,operationName:r,variables:l?void 0:u,variableHash:l?h(JSON.stringify(u||{})):void 0,method:n,elapsed:Date.now()-a,ip:b[0]||e.get("true-client-ip")||e.get("x-real-ip")||void 0,hasSetCookie:i,referer:e.get("referer")||void 0,userAgent:e.get("user-agent")||void 0,statusCode:200,errors:S,responseSize:JSON.stringify(p).length,responseHash:h(JSON.stringify(p)),varyHash:m}}function L(e){if(typeof e!="function"){console.warn("Stellate logger plugin requires a fetch function to be provided as an option.");return}}var H=process.env.STELLATE_ENDPOINT==="local"||process.env.STELLATE_ENDPOINT==="staging"?"stellate.dev":"stellate.sh";async function w({fetch:e,payload:t,token:n,serviceName:a}){return e(`https://${a}.${H}/log`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","Stellate-Logging-Token":n}})}var C=require("graphql");var F=e=>{var p,u;let t=(p=e.sendVariablesAsHash)!=null?p:!0,n=(u=e.schemaSyncing)!=null?u:!0,a=!1,r,S=async s=>{if(n){let l=(0,C.introspectionFromSchema)(s),i=Math.random()*5e3;r&&clearTimeout(r),r=setTimeout(async()=>{if(r=null,!a)try{e.fetch(`https://${e.serviceName}.${H}/schema`,{method:"POST",body:JSON.stringify({schema:l}),headers:{"Content-Type":"application/json","Stellate-Schema-Token":e.token}}).then(()=>{})}catch{}},i)}};return{async serverWillStart(){return{schemaDidLoadOrUpdate({apiSchema:s}){S(s)},async serverWillStop(){a=!0,r&&clearTimeout(r)}}},async requestDidStart(s){let l=Date.now(),{request:i}=s,{operationName:f,variables:v,http:g,query:b}=i;if(!g)return;let{headers:c,method:m}=g;if(!c.has("gcdn-request-id"))return{async willSendResponse(k){var T,P;let{response:d,source:o}=k;if(d.body.kind!=="single"){console.warn("Stellate does not currently support logging incremental results.");return}let y=d.body.singleResult,N=b||o;if(!N)return;let O=((T=i.http)==null?void 0:T.headers.get("x-graphql-client-name"))||void 0,A=((P=i.http)==null?void 0:P.headers.get("x-graphql-client-version"))||void 0,E=x({headers:c,responseHeaders:d.http.headers,operation:N,method:m,sendVariablesAsHash:t,start:l,operationName:f,errors:k.errors,response:y,variables:v,hasSetCookie:d.http.headers.has("set-cookie"),graphqlClientName:O,graphqlClientVersion:A});L(e.fetch);try{await w({fetch:e.fetch,payload:E,token:e.token,serviceName:e.serviceName})}catch{}}}}}};0&&(module.exports={createBlake3Hash,createStellateLoggerPlugin});
|
package/dist/apollo-server.mjs
CHANGED
|
@@ -23,7 +23,9 @@ function extractStellatePayload({
|
|
|
23
23
|
variables,
|
|
24
24
|
responseHeaders,
|
|
25
25
|
sendVariablesAsHash,
|
|
26
|
-
hasSetCookie
|
|
26
|
+
hasSetCookie,
|
|
27
|
+
graphqlClientName,
|
|
28
|
+
graphqlClientVersion
|
|
27
29
|
}) {
|
|
28
30
|
const forwardedFor = headers.get("x-forwarded-for");
|
|
29
31
|
const ips = forwardedFor ? forwardedFor.split(",") : [];
|
|
@@ -38,6 +40,8 @@ function extractStellatePayload({
|
|
|
38
40
|
varyHash = createBlake3Hash(variedValues);
|
|
39
41
|
}
|
|
40
42
|
return {
|
|
43
|
+
graphqlClientName,
|
|
44
|
+
graphqlClientVersion,
|
|
41
45
|
operation,
|
|
42
46
|
operationName,
|
|
43
47
|
variables: sendVariablesAsHash ? void 0 : variables,
|
|
@@ -139,6 +143,7 @@ var createStellateLoggerPlugin = (options) => {
|
|
|
139
143
|
return;
|
|
140
144
|
return {
|
|
141
145
|
async willSendResponse(respContext) {
|
|
146
|
+
var _a2, _b2;
|
|
142
147
|
const { response, source } = respContext;
|
|
143
148
|
if (response.body.kind !== "single") {
|
|
144
149
|
console.warn(
|
|
@@ -150,6 +155,8 @@ var createStellateLoggerPlugin = (options) => {
|
|
|
150
155
|
const queryString = query || source;
|
|
151
156
|
if (!queryString)
|
|
152
157
|
return;
|
|
158
|
+
const graphqlClientName = ((_a2 = request.http) == null ? void 0 : _a2.headers.get("x-graphql-client-name")) || void 0;
|
|
159
|
+
const graphqlClientVersion = ((_b2 = request.http) == null ? void 0 : _b2.headers.get("x-graphql-client-version")) || void 0;
|
|
153
160
|
const stellatePayload = extractStellatePayload({
|
|
154
161
|
headers,
|
|
155
162
|
responseHeaders: response.http.headers,
|
|
@@ -161,7 +168,9 @@ var createStellateLoggerPlugin = (options) => {
|
|
|
161
168
|
errors: respContext.errors,
|
|
162
169
|
response: respBody,
|
|
163
170
|
variables,
|
|
164
|
-
hasSetCookie: response.http.headers.has("set-cookie")
|
|
171
|
+
hasSetCookie: response.http.headers.has("set-cookie"),
|
|
172
|
+
graphqlClientName,
|
|
173
|
+
graphqlClientVersion
|
|
165
174
|
});
|
|
166
175
|
warnFetch(options.fetch);
|
|
167
176
|
try {
|