@graphprotocol/graph-cli 0.27.0 → 0.29.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/README.md +6 -6
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/tendermint.ts +554 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts +52 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/numbers.ts +11 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +47 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +150 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +2 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +2 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +2 -0
- package/examples/basic-event-handlers/package.json +1 -1
- package/examples/basic-event-handlers/yarn.lock +4 -4
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/package.json +1 -1
- package/src/codegen/schema.js +104 -25
- package/src/codegen/schema.test.js +3 -7
- package/src/command-helpers/network.js +113 -0
- package/src/command-helpers/network.test.js +78 -0
- package/src/commands/build.js +21 -1
- package/src/commands/codegen.js +1 -1
- package/src/commands/deploy.js +1 -1
- package/src/commands/init.js +19 -3
- package/src/protocols/index.js +34 -0
- package/src/protocols/tendermint/manifest.graphql +64 -0
- package/src/protocols/tendermint/subgraph.js +20 -0
- package/src/scaffold/index.js +1 -1
- package/src/subgraph.js +4 -0
- package/src/validation/manifest.js +17 -0
- package/src/validation/schema.js +120 -119
- package/tests/cli/init/ethereum/from-contract-with-abi-and-structs.stderr +2 -0
- package/tests/cli/init/ethereum/from-contract-with-abi.stderr +2 -0
- package/tests/cli/init/ethereum/from-contract-with-overloaded-elements.stderr +2 -0
- package/tests/cli/init/ethereum/from-contract.stderr +2 -0
- package/tests/cli/init/ethereum/from-example.stderr +2 -0
- package/tests/cli/init/near/from-contract.stderr +2 -0
package/src/validation/schema.js
CHANGED
|
@@ -76,12 +76,12 @@ const validateEntityDirective = def =>
|
|
|
76
76
|
def.directives.find(directive => directive.name.value === 'entity')
|
|
77
77
|
? List()
|
|
78
78
|
: immutable.fromJS([
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
{
|
|
80
|
+
loc: def.loc,
|
|
81
|
+
entity: def.name.value,
|
|
82
|
+
message: `Defined without @entity directive`,
|
|
83
|
+
},
|
|
84
|
+
])
|
|
85
85
|
|
|
86
86
|
const validateEntityID = def => {
|
|
87
87
|
let idField = def.fields.find(field => field.name.value === 'id')
|
|
@@ -99,7 +99,9 @@ const validateEntityID = def => {
|
|
|
99
99
|
if (
|
|
100
100
|
idField.type.kind === 'NonNullType' &&
|
|
101
101
|
idField.type.type.kind === 'NamedType' &&
|
|
102
|
-
idField.type.type.name.value === 'ID'
|
|
102
|
+
(idField.type.type.name.value === 'ID' ||
|
|
103
|
+
idField.type.type.name.value === 'Bytes' ||
|
|
104
|
+
idField.type.type.name.value === 'String')
|
|
103
105
|
) {
|
|
104
106
|
return List()
|
|
105
107
|
} else {
|
|
@@ -107,7 +109,7 @@ const validateEntityID = def => {
|
|
|
107
109
|
{
|
|
108
110
|
loc: idField.loc,
|
|
109
111
|
entity: def.name.value,
|
|
110
|
-
message: `Field 'id': Entity
|
|
112
|
+
message: `Field 'id': Entity ids must be of type Bytes! or String!`,
|
|
111
113
|
},
|
|
112
114
|
])
|
|
113
115
|
}
|
|
@@ -115,22 +117,22 @@ const validateEntityID = def => {
|
|
|
115
117
|
|
|
116
118
|
const validateListFieldType = (def, field) =>
|
|
117
119
|
field.type.kind === 'NonNullType' &&
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
field.type.kind === 'ListType' &&
|
|
121
|
+
field.type.type.kind !== 'NonNullType'
|
|
120
122
|
? immutable.fromJS([
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
{
|
|
124
|
+
loc: field.loc,
|
|
125
|
+
entity: def.name.value,
|
|
126
|
+
message: `\
|
|
125
127
|
Field '${field.name.value}':
|
|
126
128
|
Field has type [${field.type.type.name.value}]! but
|
|
127
129
|
must have type [${field.type.type.name.value}!]!
|
|
128
130
|
|
|
129
131
|
Reason: Lists with null elements are not supported.`,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
},
|
|
133
|
+
])
|
|
132
134
|
: field.type.kind === 'ListType' && field.type.type.kind !== 'NonNullType'
|
|
133
|
-
|
|
135
|
+
? immutable.fromJS([
|
|
134
136
|
{
|
|
135
137
|
loc: field.loc,
|
|
136
138
|
entity: def.name.value,
|
|
@@ -142,7 +144,7 @@ must have type [${field.type.type.name.value}!]
|
|
|
142
144
|
Reason: Lists with null elements are not supported.`,
|
|
143
145
|
},
|
|
144
146
|
])
|
|
145
|
-
|
|
147
|
+
: List()
|
|
146
148
|
|
|
147
149
|
const unwrapType = type => {
|
|
148
150
|
let innerTypeFromList = listType =>
|
|
@@ -159,8 +161,8 @@ const unwrapType = type => {
|
|
|
159
161
|
return type.kind === 'NonNullType'
|
|
160
162
|
? innerTypeFromNonNull(type)
|
|
161
163
|
: type.kind === 'ListType'
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
? innerTypeFromList(type)
|
|
165
|
+
: type
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
const gatherLocalTypes = defs =>
|
|
@@ -206,8 +208,8 @@ const gatherImportedTypes = defs =>
|
|
|
206
208
|
type.fields.find(
|
|
207
209
|
field => field.name.value == 'as' && field.value.kind == 'StringValue',
|
|
208
210
|
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
+
? type.fields.find(field => field.name.value == 'as').value.value
|
|
212
|
+
: undefined,
|
|
211
213
|
),
|
|
212
214
|
),
|
|
213
215
|
)
|
|
@@ -256,16 +258,15 @@ const validateInnerFieldType = (defs, def, field) => {
|
|
|
256
258
|
return availableTypes.includes(typeName)
|
|
257
259
|
? List()
|
|
258
260
|
: immutable.fromJS([
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
{
|
|
262
|
+
loc: field.loc,
|
|
263
|
+
entity: def.name.value,
|
|
264
|
+
message: `\
|
|
263
265
|
Field '${field.name.value}': \
|
|
264
|
-
Unknown type '${typeName}'.${
|
|
265
|
-
suggestion !== undefined ? ` Did you mean '${suggestion}'?` : ''
|
|
266
|
+
Unknown type '${typeName}'.${suggestion !== undefined ? ` Did you mean '${suggestion}'?` : ''
|
|
266
267
|
}`,
|
|
267
|
-
|
|
268
|
-
|
|
268
|
+
},
|
|
269
|
+
])
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
const validateEntityFieldType = (defs, def, field) =>
|
|
@@ -277,14 +278,14 @@ const validateEntityFieldType = (defs, def, field) =>
|
|
|
277
278
|
const validateEntityFieldArguments = (defs, def, field) =>
|
|
278
279
|
field.arguments.length > 0
|
|
279
280
|
? immutable.fromJS([
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
{
|
|
282
|
+
loc: field.loc,
|
|
283
|
+
entity: def.name.value,
|
|
284
|
+
message: `\
|
|
284
285
|
Field '${field.name.value}': \
|
|
285
286
|
Field arguments are not supported.`,
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
},
|
|
288
|
+
])
|
|
288
289
|
: List()
|
|
289
290
|
|
|
290
291
|
const entityFieldExists = (entityDef, name) =>
|
|
@@ -390,23 +391,23 @@ const validateEntityFields = (defs, def) =>
|
|
|
390
391
|
const validateNoImportDirective = def =>
|
|
391
392
|
def.directives.find(directive => directive.name.value == 'import')
|
|
392
393
|
? List([
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
394
|
+
immutable.fromJS({
|
|
395
|
+
loc: def.name.loc,
|
|
396
|
+
entity: def.name.value,
|
|
397
|
+
message: `@import directive only allowed on '${RESERVED_TYPE}' type`,
|
|
398
|
+
}),
|
|
399
|
+
])
|
|
399
400
|
: List()
|
|
400
401
|
|
|
401
402
|
const validateNoFulltext = def =>
|
|
402
403
|
def.directives.find(directive => directive.name.value == 'fulltext')
|
|
403
404
|
? List([
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
405
|
+
immutable.fromJS({
|
|
406
|
+
loc: def.name.loc,
|
|
407
|
+
entity: def.name.value,
|
|
408
|
+
message: `@fulltext directive only allowed on '${RESERVED_TYPE}' type`,
|
|
409
|
+
}),
|
|
410
|
+
])
|
|
410
411
|
: List()
|
|
411
412
|
|
|
412
413
|
const validateFulltextFields = (def, directive) => {
|
|
@@ -415,13 +416,13 @@ const validateFulltextFields = (def, directive) => {
|
|
|
415
416
|
['name', 'language', 'algorithm', 'include'].includes(argument.name.value)
|
|
416
417
|
? List([])
|
|
417
418
|
: List([
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
419
|
+
immutable.fromJS({
|
|
420
|
+
loc: directive.name.loc,
|
|
421
|
+
entity: def.name.value,
|
|
422
|
+
directive: fulltextDirectiveName(directive),
|
|
423
|
+
message: `found invalid argument: '${argument.name.value}', @fulltext directives only allow 'name', 'language', 'algorithm', and 'includes' arguments`,
|
|
424
|
+
}),
|
|
425
|
+
]),
|
|
425
426
|
)
|
|
426
427
|
}, List([]))
|
|
427
428
|
}
|
|
@@ -431,25 +432,25 @@ const validateFulltextName = (def, directive) => {
|
|
|
431
432
|
return name
|
|
432
433
|
? validateFulltextArgumentName(def, directive, name)
|
|
433
434
|
: List([
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
435
|
+
immutable.fromJS({
|
|
436
|
+
loc: directive.name.loc,
|
|
437
|
+
entity: def.name.value,
|
|
438
|
+
directive: fulltextDirectiveName(directive),
|
|
439
|
+
message: `@fulltext argument 'name' must be specified`,
|
|
440
|
+
}),
|
|
441
|
+
])
|
|
441
442
|
}
|
|
442
443
|
|
|
443
444
|
const validateFulltextArgumentName = (def, directive, argument) => {
|
|
444
445
|
return argument.value.kind != 'StringValue'
|
|
445
446
|
? List([
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
447
|
+
immutable.fromJS({
|
|
448
|
+
loc: directive.name.loc,
|
|
449
|
+
entity: def.name.value,
|
|
450
|
+
directive: fulltextDirectiveName(directive),
|
|
451
|
+
message: `@fulltext argument 'name' must be a string`,
|
|
452
|
+
}),
|
|
453
|
+
])
|
|
453
454
|
: List([])
|
|
454
455
|
}
|
|
455
456
|
|
|
@@ -463,13 +464,13 @@ const validateFulltextLanguage = (def, directive) => {
|
|
|
463
464
|
return language
|
|
464
465
|
? validateFulltextArgumentLanguage(def, directive, language)
|
|
465
466
|
: List([
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
467
|
+
immutable.fromJS({
|
|
468
|
+
loc: directive.name.loc,
|
|
469
|
+
entity: def.name.value,
|
|
470
|
+
directive: fulltextDirectiveName(directive),
|
|
471
|
+
message: `@fulltext argument 'language' must be specified`,
|
|
472
|
+
}),
|
|
473
|
+
])
|
|
473
474
|
}
|
|
474
475
|
|
|
475
476
|
const validateFulltextArgumentLanguage = (def, directive, argument) => {
|
|
@@ -521,13 +522,13 @@ const validateFulltextAlgorithm = (def, directive) => {
|
|
|
521
522
|
return algorithm
|
|
522
523
|
? validateFulltextArgumentAlgorithm(def, directive, algorithm)
|
|
523
524
|
: List([
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
525
|
+
immutable.fromJS({
|
|
526
|
+
loc: directive.name.loc,
|
|
527
|
+
entity: def.name.value,
|
|
528
|
+
directive: fulltextDirectiveName(directive),
|
|
529
|
+
message: `@fulltext argument 'algorithm' must be specified`,
|
|
530
|
+
}),
|
|
531
|
+
])
|
|
531
532
|
}
|
|
532
533
|
|
|
533
534
|
const validateFulltextArgumentAlgorithm = (def, directive, argument) => {
|
|
@@ -740,12 +741,12 @@ const validateImportDirectiveType = (def, directive, type) => {
|
|
|
740
741
|
return importDirectiveTypeValidators[type.kind]
|
|
741
742
|
? importDirectiveTypeValidators[type.kind](def, directive, type)
|
|
742
743
|
: List([
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
744
|
+
immutable.fromJS({
|
|
745
|
+
loc: directive.name.loc,
|
|
746
|
+
entity: def.name.value,
|
|
747
|
+
message: `Import must be one of "Name" or { name: "Name", as: "Alias" }`,
|
|
748
|
+
}),
|
|
749
|
+
])
|
|
749
750
|
}
|
|
750
751
|
|
|
751
752
|
const validateImportDirectiveArgumentTypes = (def, directive, argument) => {
|
|
@@ -815,12 +816,12 @@ const validateImportDirectiveFields = (def, directive) => {
|
|
|
815
816
|
['types', 'from'].includes(argument.name.value)
|
|
816
817
|
? List([])
|
|
817
818
|
: List([
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
819
|
+
immutable.fromJS({
|
|
820
|
+
loc: directive.name.loc,
|
|
821
|
+
entity: def.name.value,
|
|
822
|
+
message: `found invalid argument: '${argument.name.value}', @import directives only allow 'types' and 'from' arguments`,
|
|
823
|
+
}),
|
|
824
|
+
]),
|
|
824
825
|
)
|
|
825
826
|
}, List([]))
|
|
826
827
|
}
|
|
@@ -830,12 +831,12 @@ const validateImportDirectiveTypes = (def, directive) => {
|
|
|
830
831
|
return types
|
|
831
832
|
? validateImportDirectiveArgumentTypes(def, directive, types)
|
|
832
833
|
: List([
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
834
|
+
immutable.fromJS({
|
|
835
|
+
loc: directive.name.loc,
|
|
836
|
+
entity: def.name.value,
|
|
837
|
+
message: `@import argument 'types' must be specified`,
|
|
838
|
+
}),
|
|
839
|
+
])
|
|
839
840
|
}
|
|
840
841
|
|
|
841
842
|
const validateImportDirectiveFrom = (def, directive) => {
|
|
@@ -843,12 +844,12 @@ const validateImportDirectiveFrom = (def, directive) => {
|
|
|
843
844
|
return from
|
|
844
845
|
? validateImportDirectiveArgumentFrom(def, directive, from)
|
|
845
846
|
: List([
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
847
|
+
immutable.fromJS({
|
|
848
|
+
loc: directive.name.loc,
|
|
849
|
+
entity: def.name.value,
|
|
850
|
+
message: `@import argument 'from' must be specified`,
|
|
851
|
+
}),
|
|
852
|
+
])
|
|
852
853
|
}
|
|
853
854
|
|
|
854
855
|
const validateImportDirective = (def, directive) =>
|
|
@@ -892,12 +893,12 @@ const validateSubgraphSchemaDirectives = def =>
|
|
|
892
893
|
const validateTypeHasNoFields = def =>
|
|
893
894
|
def.fields.length
|
|
894
895
|
? List([
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
896
|
+
immutable.fromJS({
|
|
897
|
+
loc: def.name.loc,
|
|
898
|
+
entity: def.name.value,
|
|
899
|
+
message: `${def.name.value} type is not allowed any fields by convention`,
|
|
900
|
+
}),
|
|
901
|
+
])
|
|
901
902
|
: List()
|
|
902
903
|
|
|
903
904
|
const validateAtLeastOneExtensionField = def => List()
|
|
@@ -907,12 +908,12 @@ const typeDefinitionValidators = {
|
|
|
907
908
|
def.name && def.name.value == RESERVED_TYPE
|
|
908
909
|
? List.of(...validateSubgraphSchemaDirectives(def), ...validateTypeHasNoFields(def))
|
|
909
910
|
: List.of(
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
911
|
+
...validateEntityDirective(def),
|
|
912
|
+
...validateEntityID(def),
|
|
913
|
+
...validateEntityFields(defs, def),
|
|
914
|
+
...validateNoImportDirective(def),
|
|
915
|
+
...validateNoFulltext(def),
|
|
916
|
+
),
|
|
916
917
|
ObjectTypeExtension: (_defs, def) => validateAtLeastOneExtensionField(def),
|
|
917
918
|
}
|
|
918
919
|
|