Skip to content

Commit affb5a8

Browse files
committed
Block tracking tests
1 parent 469f452 commit affb5a8

File tree

15 files changed

+721
-654
lines changed

15 files changed

+721
-654
lines changed
Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
import { createRenameFieldTransform, createRenameTypeTransform, defineConfig as defineComposeConfig, loadGraphQLHTTPSubgraph } from '@graphprotocol/client-compose-cli';
2-
import { GraphQLID } from 'graphql';
1+
import {
2+
createRenameFieldTransform,
3+
createRenameTypeTransform,
4+
defineConfig as defineComposeConfig,
5+
loadGraphQLHTTPSubgraph,
6+
} from '@graphprotocol/client-compose-cli'
7+
import { GraphQLID } from 'graphql'
38

49
export const composeConfig = defineComposeConfig({
5-
subgraphs: [
6-
{
7-
sourceHandler: loadGraphQLHTTPSubgraph('nft', {
8-
endpoint: 'https://api.thegraph.com/subgraphs/name/amxx/eip721-subgraph',
9-
}),
10-
transforms: [
11-
// Resolve conflicts between subgraphs
12-
createRenameFieldTransform((field, fieldName, typeName) => {
13-
if (typeName === 'Account' && fieldName === 'id') {
14-
field.type = GraphQLID;
15-
}
16-
return fieldName;
17-
}),
18-
createRenameTypeTransform(type => {
19-
if (type.name === 'Account') {
20-
return 'User';
21-
}
22-
return type.name;
23-
})
24-
]
25-
},
26-
{
27-
sourceHandler: loadGraphQLHTTPSubgraph('uniswap', {
28-
endpoint: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2',
29-
})
30-
}
31-
]
32-
})
10+
subgraphs: [
11+
{
12+
sourceHandler: loadGraphQLHTTPSubgraph('nft', {
13+
endpoint: 'https://api.thegraph.com/subgraphs/name/amxx/eip721-subgraph',
14+
}),
15+
transforms: [
16+
// Resolve conflicts between subgraphs
17+
createRenameFieldTransform((field, fieldName, typeName) => {
18+
if (typeName === 'Account' && fieldName === 'id') {
19+
field.type = GraphQLID
20+
}
21+
return fieldName
22+
}),
23+
createRenameTypeTransform((type) => {
24+
if (type.name === 'Account') {
25+
return 'User'
26+
}
27+
return type.name
28+
}),
29+
],
30+
},
31+
{
32+
sourceHandler: loadGraphQLHTTPSubgraph('uniswap', {
33+
endpoint: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2',
34+
}),
35+
},
36+
],
37+
})

examples/composition/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@graphprotocol/client-compose-cli": "^0.0.0",
1313
"@graphprotocol/client-runtime": "^0.0.0",
14-
"@graphql-mesh/transport-http": "^0.0.3",
14+
"@graphql-mesh/transport-http": "^0.1.4",
1515
"concurrently": "^8.0.1",
1616
"graphql": "^16.6.0",
1717
"nodemon": "^3.0.0",

examples/composition/src/index.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getExecutorForFusiongraph } from '@graphprotocol/client-runtime'
1+
import { getExecutor } from '@graphprotocol/client-runtime'
22
import fusiongraph from '../fusiongraph'
33
import { parse } from 'graphql'
44

5-
const executor = getExecutorForFusiongraph({
5+
const executor = getExecutor({
66
fusiongraph,
77
})
88

@@ -13,7 +13,8 @@ async function main() {
1313
# Shared unique identifier field
1414
id
1515
# Field from uniswap source
16-
ERC721tokens(first: 1) {
16+
ERC721tokens(first: 1001) {
17+
# Testing auto pagination by exceeding the limit of 1000
1718
id
1819
uri
1920
}
@@ -29,14 +30,28 @@ async function main() {
2930
...UserFields
3031
}
3132
# Get base entity from uniswap source
32-
user(id: "0x72ba1965320ab5352fd6d68235cc3c5306a6ffa2") {
33-
...UserFields
34-
}
33+
# user(id: "0x72ba1965320ab5352fd6d68235cc3c5306a6ffa2") {
34+
# ...UserFields
35+
#}
3536
}
3637
`),
3738
})
3839

39-
console.log(response)
40+
if (Symbol.asyncIterator in response) {
41+
throw new Error('Unexpected async iterator response')
42+
}
43+
44+
if ('errors' in response && response.errors?.length) {
45+
for (const error of response.errors) {
46+
console.error(error.message)
47+
}
48+
} else {
49+
console.log(`
50+
Account: ${response.data?.account.id} has
51+
${response.data?.account.ERC721tokens.length} ERC721 tokens and
52+
${response.data?.account.liquidityPositions.length} liquidity positions
53+
`)
54+
}
4055
}
4156

4257
main().catch((e) => console.error(`Failed to run example:`, e))

examples/transforms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"@graphprotocol/client-cli": "^3.0.0",
11-
"@graphql-mesh/transform-prefix": "^0.94.0",
11+
"@graphql-mesh/transform-prefix": "^0.97.4",
1212
"graphql": "^16.6.0"
1313
}
1414
}

packages/auto-type-merging/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
},
4848
"dependencies": {
4949
"@graphql-mesh/transform-type-merging": "^0.94.0",
50+
"@graphql-mesh/fusion-runtime": "^0.2.5",
5051
"tslib": "^2.4.0"
5152
},
5253
"peerDependencies": {

0 commit comments

Comments
 (0)