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AAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,GACxF,CAAC;aACH;YACD,MAAM;QACR,KAAK,uBAAY,CAAC,SAAS;YACzB,IAAI,iBAAiB,CAAC,QAAQ,EAAE;gBAC9B,eAAe,yBAAQ,OAAO,KAAE,IAAI,EAAE,uBAAY,CAAC,iBAAiB,GAAE,CAAC;aACxE;YACD,MAAM;QACR,KAAK,uBAAY,CAAC,QAAQ;YACxB,IAAI,iBAAiB,CAAC,QAAQ,EAAE;gBAC9B,eAAe,yBAAQ,OAAO,KAAE,IAAI,EAAE,uBAAY,CAAC,iBAAiB,GAAE,CAAC;aACxE;YACD,MAAM;QACR,KAAK,uBAAY,CAAC,YAAY;YAC5B,IAAI,iBAAiB,CAAC,QAAQ,EAAE;gBAC9B,eAAe,GAAG,IAAI,CAAC;aACxB;YACD,MAAM;QACR,KAAK,uBAAY,CAAC,oBAAoB;YACpC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE;gBAC/B,eAAe,GAAG,IAAI,CAAC;aACxB;YACD,MAAM;QACR;YACE,MAAM;KACT;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import { ConnectionContext } from '../server';\nimport MessageTypes from '../message-types';\n\nexport const parseLegacyProtocolMessage = (connectionContext: ConnectionContext, message: any) => {\n let messageToReturn = message;\n\n switch (message.type) {\n case MessageTypes.INIT:\n connectionContext.isLegacy = true;\n messageToReturn = { ...message, type: MessageTypes.GQL_CONNECTION_INIT };\n break;\n case MessageTypes.SUBSCRIPTION_START:\n messageToReturn = {\n id: message.id,\n type: MessageTypes.GQL_START,\n payload: {\n query: message.query,\n operationName: message.operationName,\n variables: message.variables,\n },\n };\n break;\n case MessageTypes.SUBSCRIPTION_END:\n messageToReturn = { ...message, type: MessageTypes.GQL_STOP };\n break;\n case MessageTypes.GQL_CONNECTION_ACK:\n if (connectionContext.isLegacy) {\n messageToReturn = { ...message, type: MessageTypes.INIT_SUCCESS };\n }\n break;\n case MessageTypes.GQL_CONNECTION_ERROR:\n if (connectionContext.isLegacy) {\n messageToReturn = {\n ...message, type: MessageTypes.INIT_FAIL,\n payload: message.payload.message ? { error: message.payload.message } : message.payload,\n };\n }\n break;\n case MessageTypes.GQL_ERROR:\n if (connectionContext.isLegacy) {\n messageToReturn = { ...message, type: MessageTypes.SUBSCRIPTION_FAIL };\n }\n break;\n case MessageTypes.GQL_DATA:\n if (connectionContext.isLegacy) {\n messageToReturn = { ...message, type: MessageTypes.SUBSCRIPTION_DATA };\n }\n break;\n case MessageTypes.GQL_COMPLETE:\n if (connectionContext.isLegacy) {\n messageToReturn = null;\n }\n break;\n case MessageTypes.SUBSCRIPTION_SUCCESS:\n if (!connectionContext.isLegacy) {\n messageToReturn = null;\n }\n break;\n default:\n break;\n }\n\n return messageToReturn;\n};\n"]}
|