atulmy/gql-query-builder

The 3.1.0 release's build is missing exports

toadkicker opened this issue · 2 comments

Hello,

I was testing today and it seems like there is a difference between the builds from my local build output and what was in the 3.1.0 npm package. It's like it wasn't built before being published? I don't know.

1a2,12
> var __assign = (this && this.__assign) || function () {
>     __assign = Object.assign || function(t) {
>         for (var s, i = 1, n = arguments.length; i < n; i++) {
>             s = arguments[i];
>             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
>                 t[p] = s[p];
>         }
>         return t;
>     };
>     return __assign.apply(this, arguments);
> };
3,9c14,19
< var adapters_1 = require("./adapters");
< exports.adapters = adapters_1.default;
< var DefaultMutationAdapter_1 = require("./adapters/DefaultMutationAdapter");
< var DefaultQueryAdapter_1 = require("./adapters/DefaultQueryAdapter");
< var DefaultSubscriptionAdapter_1 = require("./adapters/DefaultSubscriptionAdapter");
< function queryOperation(options, adapter) {
<     var defaultAdapter;
---
> var OperationType;
> (function (OperationType) {
>     OperationType["Mutation"] = "mutation";
>     OperationType["Query"] = "query";
> })(OperationType || (OperationType = {}));
> function queryOperation(options) {
11,20c21
<         if (adapter) {
<             var customAdapter = new adapter(options);
<             return customAdapter.queriesBuilder(options);
<         }
<         defaultAdapter = new DefaultQueryAdapter_1.default(options);
<         return defaultAdapter.queriesBuilder(options);
<     }
<     if (adapter) {
<         var customAdapter = new adapter(options);
<         return customAdapter.queryBuilder();
---
>         return queriesBuilder(options);
22,23c23
<     defaultAdapter = new DefaultQueryAdapter_1.default(options);
<     return defaultAdapter.queryBuilder();
---
>     return queryBuilder(options);
26,28c26,33
< function mutationOperation(options, adapter) {
<     var customAdapter;
<     var defaultAdapter;
---
> function queryBuilder(_a) {
>     var operation = _a.operation, _b = _a.fields, fields = _b === void 0 ? [] : _b, _c = _a.variables, variables = _c === void 0 ? {} : _c;
>     return operationWrapperTemplate(OperationType.Query, variables, operationTemplate({ variables: variables, operation: operation, fields: fields }));
> }
> function queriesBuilder(queries) {
>     return operationWrapperTemplate(OperationType.Query, resolveVariables(queries), queries.map(operationTemplate).join("\n  "));
> }
> function mutationOperation(options) {
30,41c35
<         if (adapter) {
<             // @ts-ignore
<             customAdapter = new adapter(options);
<             return customAdapter.mutationsBuilder(options);
<         }
<         defaultAdapter = new DefaultMutationAdapter_1.default(options);
<         return defaultAdapter.mutationsBuilder(options);
<     }
<     if (adapter) {
<         // @ts-ignore
<         customAdapter = new adapter(options);
<         return customAdapter.mutationBuilder();
---
>         return mutationsBuilder(options);
43,44c37
<     defaultAdapter = new DefaultMutationAdapter_1.default(options);
<     return defaultAdapter.mutationBuilder();
---
>     return mutationBuilder(options);
47,54c40,123
< function subscriptionOperation(options, adapter) {
<     var customAdapter;
<     var defaultAdapter;
<     if (Array.isArray(options)) {
<         if (adapter) {
<             // @ts-ignore
<             customAdapter = new adapter(options);
<             return customAdapter.subscriptionsBuilder(options);
---
> function mutationBuilder(_a) {
>     var operation = _a.operation, _b = _a.fields, fields = _b === void 0 ? [] : _b, _c = _a.variables, variables = _c === void 0 ? {} : _c;
>     return operationWrapperTemplate(OperationType.Mutation, variables, operationTemplate({ variables: variables, operation: operation, fields: fields }));
> }
> function mutationsBuilder(mutations) {
>     return operationWrapperTemplate(OperationType.Mutation, resolveVariables(mutations), mutations.map(operationTemplate).join("\n  "));
> }
> function resolveVariables(operations) {
>     var ret = {};
>     operations.forEach(function (_a) {
>         var variables = _a.variables;
>         ret = __assign({}, ret, variables);
>     });
>     return ret;
> }
> function operationWrapperTemplate(type, variables, content) {
>     return {
>         query: type + " " + queryDataArgumentAndTypeMap(variables) + " {\n  " + content + "\n}",
>         variables: queryVariablesMap(variables)
>     };
> }
> function operationTemplate(_a) {
>     var variables = _a.variables, operation = _a.operation, fields = _a.fields;
>     return operation + " " + queryDataNameAndArgumentMap(variables) + " " + (fields && fields.length > 0
>         ? "{\n    " + queryFieldsMap(fields) + "\n  }"
>         : "");
> }
> // Convert object to name and argument map. eg: (id: $id)
> function queryDataNameAndArgumentMap(variables) {
>     return variables && Object.keys(variables).length
>         ? "(" + Object.keys(variables).reduce(function (dataString, key, i) {
>             return "" + dataString + (i !== 0 ? ", " : "") + key + ": $" + key;
>         }, "") + ")"
>         : "";
> }
> // Convert object to argument and type map. eg: ($id: Int)
> function queryDataArgumentAndTypeMap(variables) {
>     return Object.keys(variables).length
>         ? "(" + Object.keys(variables).reduce(function (dataString, key, i) {
>             return "" + dataString + (i !== 0 ? ", " : "") + "$" + key + ": " + queryDataType(variables[key]);
>         }, "") + ")"
>         : "";
> }
> // Fields selection map. eg: { id, name }
> function queryFieldsMap(fields) {
>     return fields
>         ? fields
>             .map(function (field) {
>             return typeof field === "object"
>                 ? Object.keys(field)[0] + " { " + queryFieldsMap(Object.values(field)[0]) + " }"
>                 : "" + field;
>         })
>             .join(", ")
>         : "";
> }
> // Variables map. eg: { "id": 1, "name": "Jon Doe" }
> function queryVariablesMap(variables) {
>     var variablesMapped = {};
>     Object.keys(variables).map(function (key) {
>         variablesMapped[key] =
>             typeof variables[key] === "object"
>                 ? variables[key].value
>                 : variables[key];
>     });
>     return variablesMapped;
> }
> // Get GraphQL equivalent type of data passed (String, Int, Float, Boolean)
> function queryDataType(variable) {
>     var type = "String";
>     var value = typeof variable === "object" ? variable.value : variable;
>     if (variable.type !== undefined) {
>         type = variable.type;
>     }
>     else {
>         switch (typeof value) {
>             case "object":
>                 type = "Object";
>                 break;
>             case "boolean":
>                 type = "Boolean";
>                 break;
>             case "number":
>                 type = value % 1 === 0 ? "Int" : "Float";
>                 break;
56,57d124
<         defaultAdapter = new DefaultSubscriptionAdapter_1.default(options);
<         return defaultAdapter.subscriptionsBuilder(options);
59,62c126,127
<     if (adapter) {
<         // @ts-ignore
<         customAdapter = new adapter(options);
<         return customAdapter.subscriptionBuilder();
---
>     if (typeof variable === "object" && variable.required) {
>         type += "!";
64,65c129
<     defaultAdapter = new DefaultSubscriptionAdapter_1.default(options);
<     return defaultAdapter.subscriptionBuilder();
---
>     return type;
67d130
< exports.subscription = subscriptionOperation;

Thanks, fixed now. Can you please check again and confirm on same?

fixed!