Skip to content

Commit 00427b7

Browse files
committed
Updated PR with comments
1 parent 255005c commit 00427b7

File tree

9 files changed

+65
-5
lines changed

9 files changed

+65
-5
lines changed

schemas/ethereum.graphql renamed to src/protocols/ethereum/manifest.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Each referenced type's in any of the types below must be listed
2+
# here either as `scalar` or `type` for the validation code to work
3+
# properly.
4+
#
5+
# That's why `String` is listed as a scalar even though it's built-in
6+
# GraphQL basic types.
17
scalar String
28
scalar File
39
scalar BigInt

src/protocols/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const immutable = require('immutable')
22
const EthereumTypeGenerator = require('./ethereum/type-generator')
33
const EthereumTemplateCodeGen = require('./ethereum/codegen/template')
4-
const NearTemplateCodeGen = require('./near/codegen/template')
54
const EthereumABI = require('./ethereum/abi')
65
const EthereumSubgraph = require('./ethereum/subgraph')
76
const NearSubgraph = require('./near/subgraph')

schemas/near.graphql renamed to src/protocols/near/manifest.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Each referenced type's in any of the types below must be listed
2+
# here either as `scalar` or `type` for the validation code to work
3+
# properly.
4+
#
5+
# That's why `String` is listed as a scalar even though it's built-in
6+
# GraphQL basic types.
17
scalar String
28
scalar File
39
scalar BigInt

src/subgraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = class Subgraph {
5151
// Parse the default subgraph schema
5252
let schema = graphql.parse(
5353
await fs.readFile(
54-
path.join(__dirname, '..', 'schemas', `${protocol.name}.graphql`),
54+
path.join(__dirname, 'protocols', protocol.name, `manifest.graphql`),
5555
'utf-8',
5656
),
5757
)

tests/cli/validation.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ describe('Validation', () => {
99
exitCode: 1,
1010
},
1111
)
12+
cliTest(
13+
'Invalid subgraph manifest (cannot infer protocol)',
14+
['codegen', '--skip-migrations'],
15+
'validation/invalid-manifest-cannot-infer-protocol',
16+
{
17+
exitCode: 1,
18+
},
19+
)
1220
cliTest(
1321
'ABI not found in data source',
1422
['codegen', '--skip-migrations'],
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Load subgraph from subgraph.yaml
2+
✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml:
3+
4+
Path: /
5+
Unable to determine for which protocol manifest file is built for. Ensure you have at least one 'dataSources' and/or 'templates' elements defined in your subgraph.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
schema:
2+
file: ./non-existent.grapqhl
3+
dataSources:
4+
- name: 5
5+
abis:
6+
name: Foo
7+
mapping:
8+
- 12
9+
- 13
10+
- 14
11+
templates:
12+
field: foo
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
- Load subgraph from subgraph.yaml
22
✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml:
33

4-
Path: /
5-
Unable to determine for which protocol manifest file is built for. Ensure you have at least one 'dataSources' and/or 'templates' elements defined in your subgraph.
4+
Path: specVersion
5+
No value provided
6+
7+
Path: schema > file
8+
File does not exist: non-existent.grapqhl
9+
10+
Path: dataSources > 0 > name
11+
Expected string, found number:
12+
5
13+
14+
Path: dataSources > 0 > source
15+
No value provided
16+
17+
Path: dataSources > 0 > mapping
18+
Expected map, found list:
19+
- 12
20+
- 13
21+
- 14
22+
23+
Path: dataSources > 0
24+
Unexpected key in map: abis
25+
26+
Path: templates
27+
Expected list, found map:
28+
field: foo

tests/cli/validation/invalid-manifest/subgraph.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
schema:
22
file: ./non-existent.grapqhl
33
dataSources:
4-
- name: 5
4+
- kind: ethereum/contract
5+
name: 5
56
abis:
67
name: Foo
78
mapping:

0 commit comments

Comments
 (0)