@hostlink/nuxt-light 0.0.6 → 0.0.7
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/module.json +1 -1
- package/dist/runtime/composables/m.d.ts +1 -1
- package/dist/runtime/composables/m.mjs +51 -73
- package/dist/runtime/composables/mutation.d.ts +1 -1
- package/dist/runtime/composables/mutation.mjs +12 -23
- package/dist/runtime/composables/t.d.ts +1 -1
- package/dist/runtime/composables/t.mjs +5 -8
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function (operation: any, args: any, fields?: never[]): Promise<any>;
|
|
@@ -1,73 +1,51 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
query: graphql_query
|
|
53
|
-
}));
|
|
54
|
-
fd.append("map", JSON.stringify(map));
|
|
55
|
-
for (let i = 0; i < map_values.length; i++) {
|
|
56
|
-
fd.append(i, map_values[i]);
|
|
57
|
-
}
|
|
58
|
-
data = (await service.post("/api/", fd)).data;
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
data = (await service.post("/api/", {
|
|
62
|
-
query: graphql_query
|
|
63
|
-
})).data;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (data.errors) {
|
|
67
|
-
throw new Error(data.errors[0].message);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return data.data[operation];
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { jsonToGraphQLQuery } from "json-to-graphql-query";
|
|
3
|
+
export default async function(operation, args, fields = []) {
|
|
4
|
+
const mutation = {
|
|
5
|
+
mutation: {}
|
|
6
|
+
};
|
|
7
|
+
mutation.mutation[operation] = {};
|
|
8
|
+
if (args) {
|
|
9
|
+
mutation.mutation[operation].__args = args;
|
|
10
|
+
}
|
|
11
|
+
let map = {};
|
|
12
|
+
let map_values = [];
|
|
13
|
+
fields.forEach((field) => {
|
|
14
|
+
if (typeof field === "string") {
|
|
15
|
+
mutation.mutation[operation][field] = true;
|
|
16
|
+
} else {
|
|
17
|
+
mutation.mutation.__variables = mutation.mutation.__variables || {};
|
|
18
|
+
let i = 0;
|
|
19
|
+
Object.entries(field.__variables).forEach(([key, value]) => {
|
|
20
|
+
mutation.mutation.__variables[key] = value.type;
|
|
21
|
+
map[i] = ["variables." + key];
|
|
22
|
+
map_values.push(value.value);
|
|
23
|
+
i++;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const graphql_query = jsonToGraphQLQuery(mutation);
|
|
28
|
+
let service = axios.create({
|
|
29
|
+
withCredentials: true
|
|
30
|
+
});
|
|
31
|
+
let data = null;
|
|
32
|
+
if (map_values.length) {
|
|
33
|
+
const fd = new FormData();
|
|
34
|
+
fd.append("operations", JSON.stringify({
|
|
35
|
+
query: graphql_query
|
|
36
|
+
}));
|
|
37
|
+
fd.append("map", JSON.stringify(map));
|
|
38
|
+
for (let i = 0; i < map_values.length; i++) {
|
|
39
|
+
fd.append(i, map_values[i]);
|
|
40
|
+
}
|
|
41
|
+
data = (await service.post("/api/", fd)).data;
|
|
42
|
+
} else {
|
|
43
|
+
data = (await service.post("/api/", {
|
|
44
|
+
query: graphql_query
|
|
45
|
+
})).data;
|
|
46
|
+
}
|
|
47
|
+
if (data.errors) {
|
|
48
|
+
throw new Error(data.errors[0].message);
|
|
49
|
+
}
|
|
50
|
+
return data.data[operation];
|
|
51
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function (options: any): Promise<any>;
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
import { mutation } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const data = (await service.post("/api/", mutation(options))).data;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (data.errors) {
|
|
17
|
-
throw new Error(data.errors[0].message);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { mutation } from "gql-query-builder";
|
|
3
|
+
export default async function(options) {
|
|
4
|
+
let service = axios.create({
|
|
5
|
+
withCredentials: true
|
|
6
|
+
});
|
|
7
|
+
const data = (await service.post("/api/", mutation(options))).data;
|
|
8
|
+
if (data.errors) {
|
|
9
|
+
throw new Error(data.errors[0].message);
|
|
10
|
+
}
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function (x: any): string;
|