antelopeql 2.0.0-rc.16 → 2.0.0-rc.18
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.
|
@@ -69,10 +69,13 @@ import {
|
|
|
69
69
|
* })
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
export default function build_graphql_fields_from_abis(abi_list) {
|
|
72
|
+
export default function build_graphql_fields_from_abis(abi_list, chain = "") {
|
|
73
73
|
const contract_query_fields = {};
|
|
74
74
|
const contract_mutation_fields = {};
|
|
75
75
|
const ast_list = {};
|
|
76
|
+
const chainName = chain
|
|
77
|
+
.toUpperCase()
|
|
78
|
+
.padStart(!chain.length ? 0 : chain.length + 1, "_");
|
|
76
79
|
|
|
77
80
|
for (const { abi, account_name } of abi_list) {
|
|
78
81
|
const name = account_name.replace(/\./gmu, "_");
|
|
@@ -83,14 +86,15 @@ export default function build_graphql_fields_from_abis(abi_list) {
|
|
|
83
86
|
const { query_fields, mutation_fields } = get_graphql_fields_from_AST(
|
|
84
87
|
AST,
|
|
85
88
|
abi,
|
|
86
|
-
name
|
|
89
|
+
name,
|
|
90
|
+
chainName
|
|
87
91
|
);
|
|
88
92
|
|
|
89
93
|
if (Object.keys(query_fields).length)
|
|
90
94
|
contract_query_fields[name] = {
|
|
91
95
|
name,
|
|
92
96
|
type: new GraphQLObjectType({
|
|
93
|
-
name: name
|
|
97
|
+
name: `${name}_query${chainName}`,
|
|
94
98
|
fields: query_fields
|
|
95
99
|
}),
|
|
96
100
|
resolve(root, arg, getContext, { fieldName, ...info }) {
|
|
@@ -116,7 +120,7 @@ export default function build_graphql_fields_from_abis(abi_list) {
|
|
|
116
120
|
if (Object.keys(mutation_fields).length)
|
|
117
121
|
contract_mutation_fields[name] = {
|
|
118
122
|
type: new GraphQLInputObjectType({
|
|
119
|
-
name,
|
|
123
|
+
name: name + chainName,
|
|
120
124
|
fields: mutation_fields
|
|
121
125
|
})
|
|
122
126
|
};
|
|
@@ -112,7 +112,12 @@ function Wrap(type, { optional, list }) {
|
|
|
112
112
|
* @param {String} [account_name] Blockchain account name.
|
|
113
113
|
* @returns {Object} GraphQL query and mutation fields.
|
|
114
114
|
*/
|
|
115
|
-
export function get_graphql_fields_from_AST(
|
|
115
|
+
export function get_graphql_fields_from_AST(
|
|
116
|
+
AST,
|
|
117
|
+
ABI,
|
|
118
|
+
account_name = "",
|
|
119
|
+
chainName = ""
|
|
120
|
+
) {
|
|
116
121
|
const { tables, actions } = ABI;
|
|
117
122
|
const gql_account_name = account_name.replace(/\./gmu, "_") + "_";
|
|
118
123
|
|
|
@@ -139,7 +144,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
|
|
|
139
144
|
if ($info.object) {
|
|
140
145
|
if (!GQL_TYPES[type])
|
|
141
146
|
GQL_TYPES[type] = new GraphQLObjectType({
|
|
142
|
-
name: gql_account_name + type,
|
|
147
|
+
name: gql_account_name + type + chainName,
|
|
143
148
|
fields: buildQGL(AST[type])
|
|
144
149
|
});
|
|
145
150
|
|
|
@@ -160,7 +165,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
|
|
|
160
165
|
queryTypes[table_type] = {
|
|
161
166
|
type: new GraphQLList(
|
|
162
167
|
new GraphQLObjectType({
|
|
163
|
-
name: gql_account_name + table_type + "_query",
|
|
168
|
+
name: gql_account_name + table_type + "_query" + chainName,
|
|
164
169
|
fields: buildQGL(table_fields)
|
|
165
170
|
})
|
|
166
171
|
),
|
|
@@ -196,7 +201,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
|
|
|
196
201
|
if ($info.object) {
|
|
197
202
|
if (!GQL_MTYPES[type])
|
|
198
203
|
GQL_MTYPES[type] = new GraphQLInputObjectType({
|
|
199
|
-
name: gql_account_name + "input_" + type,
|
|
204
|
+
name: gql_account_name + "input_" + type + chainName,
|
|
200
205
|
fields: buildQGL(AST[type])
|
|
201
206
|
});
|
|
202
207
|
acc = { ...acc, [name]: { type: Wrap(GQL_MTYPES[type], $info) } };
|
|
@@ -209,7 +214,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
|
|
|
209
214
|
if (!mutationTypes[action_type]) {
|
|
210
215
|
mutationTypes[action_type] = {
|
|
211
216
|
type: new GraphQLInputObjectType({
|
|
212
|
-
name: gql_account_name + action_type,
|
|
217
|
+
name: gql_account_name + action_type + chainName,
|
|
213
218
|
description: ricardian_contract
|
|
214
219
|
.replace(/(https?|http|ftp):\/\/[^\s$.?#].[^\s]*$/gmu, "")
|
|
215
220
|
.replace(/icon:/gmu, "")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antelopeql",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.18",
|
|
4
4
|
"description": "A GraphQL implementation for interacting with Antelope based blockchains.",
|
|
5
5
|
"repository": "github:pur3miish/antelopeql",
|
|
6
6
|
"bugs": "https://github.com/pur3miish/antelopeql/issues",
|