Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added subgraph-query/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions subgraph-query/wrapper/assemblyscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
node_modules
wrap
.polywrap
Empty file.
1 change: 1 addition & 0 deletions subgraph-query/wrapper/assemblyscript/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.0
15 changes: 15 additions & 0 deletions subgraph-query/wrapper/assemblyscript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Subgraph Query demo wrapper
Subgraph query demo wrapper showcases how to query subgraph using our graph plugin. For more information on how this project works, and a step by step on how to extend its behavior, see the documentation [here](https://docs.polywrap.io/).

# How To Run

## Install Dependencies
`nvm install && nvm use`
`yarn`

## Build
`yarn build`

## Test
`yarn test:e2e`
`yarn test:workflow`
17 changes: 17 additions & 0 deletions subgraph-query/wrapper/assemblyscript/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
collectCoverage: false,
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/e2e/**/?(*.)+(spec|test).[jt]s?(x)"],
modulePathIgnorePatterns: [
"./src/__tests__/mutation",
"./src/__tests__/query",
"./src/__tests__/utils",
],
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
diagnostics: false,
},
},
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions subgraph-query/wrapper/assemblyscript/meta/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions subgraph-query/wrapper/assemblyscript/meta/test.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation {
deployContract(
connection: $connection
)
}
5 changes: 5 additions & 0 deletions subgraph-query/wrapper/assemblyscript/meta/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"connection": {
"networkNameOrChainId": "rinkeby"
}
}
33 changes: 33 additions & 0 deletions subgraph-query/wrapper/assemblyscript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "subgraph-query-as",
"description": "Subgraph query demo as assemblyscript wrapper",
"private": true,
"version": "0.0.1-prealpha.89",
"scripts": {
"build": "npx polywrap build",
"postbuild": "yarn codegen:app",
"codegen": "npx polywrap codegen",
"codegen:app": "npx polywrap app codegen -m ./src/__tests__/types/polywrap.app.yaml -c ./src/__tests__/types/wrap",
"test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs",
"test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs",
"deploy": "npx polywrap deploy",
"test": "yarn test:e2e && yarn test:workflow",
"test:e2e": "jest --passWithNoTests --runInBand --verbose",
"test:workflow": "npx polywrap run ./workflows/e2e.yaml"
},
"devDependencies": {
"@polywrap/ethereum-plugin-js": "0.0.1-prealpha.89",
"@types/jest": "27.0.3",
"@types/node": "16.11.11",
"@types/prettier": "2.6.0",
"assemblyscript": "0.19.1",
"jest": "26.6.3",
"polywrap": "0.0.1-prealpha.89",
"ts-jest": "26.5.4",
"ts-node": "8.10.2",
"typescript": "4.0.7"
},
"dependencies": {
"@polywrap/wasm-as": "0.0.1-prealpha.89"
}
}
8 changes: 8 additions & 0 deletions subgraph-query/wrapper/assemblyscript/polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
format: 0.0.1-prealpha.2
docker:
name: subgraph-query-wasm-as
config:
node_version: "16.13.0"
include:
- ./package.json
- ./src
5 changes: 5 additions & 0 deletions subgraph-query/wrapper/assemblyscript/polywrap.deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
format: 0.0.1-prealpha.1
stages:
ipfs_deploy:
package: ipfs
uri: fs/./build
13 changes: 13 additions & 0 deletions subgraph-query/wrapper/assemblyscript/polywrap.meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
format: 0.0.1-prealpha.3
displayName: Subgraph query
subtext: wrapper for quering subgraph
description: wrapper for quering subgraph
tags:
- subgraph
- query
repository: https://github.com/test/test
icon: ./meta/icon.png
links:
- name: test link
icon: ./meta/link.svg
url: http://link.com/path
8 changes: 8 additions & 0 deletions subgraph-query/wrapper/assemblyscript/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
format: 0.0.1-prealpha.9
name: subgraph-query-as
language: wasm/assemblyscript
build: ./polywrap.build.yaml
meta: ./polywrap.meta.yaml
deploy: ./polywrap.deploy.yaml
module: ./src/index.ts
schema: ./src/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { PolywrapClient } from "@polywrap/client-js";
import { buildWrapper, runCLI } from "@polywrap/test-env-js";
import * as App from "../types/wrap";
import path from "path";

jest.setTimeout(500000);

describe("SubgraphQuery", () => {
let client: PolywrapClient;

const wrapperPath: string = path.join(
path.resolve(__dirname),
"..",
"..",
".."
);
const wrapperUri = `fs/${wrapperPath}/build`;

beforeAll(async () => {
client = new PolywrapClient();

await buildWrapper(wrapperPath);

await runCLI({
args: ["app", "codegen", "-c", "./wrap"],
cwd: path.join(__dirname, "..", "types"),
});
});

it("subgraph-query", async () => {
const response = await App.SubgraphQuery_Module.subgraphQuery(
{
subgraphAuthor: "ensdomains",
subgraphName: "ens",
query: "{\ndomains(first: 5) {\nid\nname\nlabelName\nlabelhash\n}\n}",
},
client,
wrapperUri
);

expect(response).toBeTruthy();
expect(response.error).toBeFalsy();
expect(response.data).not.toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
format: 0.0.1-prealpha.1
language: app/typescript
schema: ./schema.graphql
import_redirects:
- uri: "wrap://ens/subgraph-query.eth"
schema: "../../../build/schema.graphql"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import * into SubgraphQuery from "ens/subgraph-query.eth"
28 changes: 28 additions & 0 deletions subgraph-query/wrapper/assemblyscript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
Input_subgraphQuery,
Subgraph_Module
} from "./wrap";
import { JSON } from "@polywrap/wasm-as";

export function subgraphQuery(input: Input_subgraphQuery): JSON.Value {
const response = Subgraph_Module.querySubgraph({
subgraphAuthor: input.subgraphAuthor,
subgraphName: input.subgraphName,
query: input.query
}).unwrap();

const json = JSON.parse(response);

if (!json.isObj) {
throw new Error(
"Subgraph response is not an object.\n" +
`Author: ${input.subgraphAuthor}\n` +
`Subgraph: ${input.subgraphName}\n` +
`Query: ${input.query}\n` +
`Response: ${response}`
);
}

const obj = json as JSON.Obj;
return obj.valueOf().get("data") as JSON.Value;
}
9 changes: 9 additions & 0 deletions subgraph-query/wrapper/assemblyscript/src/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import { Module } into Subgraph from "ens/graph-node.polywrap.eth"

type Module {
subgraphQuery(
subgraphAuthor: String!
subgraphName: String!
query: String!
): JSON!
}
12 changes: 12 additions & 0 deletions subgraph-query/wrapper/assemblyscript/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "assemblyscript/std/assembly.json",
"compilerOptions": {
"outDir": "build"
},
"include": [
"./src/**/*.ts",
],
"exclude": [
"./src/__tests__/e2e/**/*.ts"
]
}
28 changes: 28 additions & 0 deletions subgraph-query/wrapper/assemblyscript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": [
"es2020",
"es2015",
"es5",
"dom"
],
"esModuleInterop": true,
"outDir": "build",
"moduleResolution": "node",
"declaration": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"module": "commonjs",
"sourceMap": true,
"target": "es5",
"resolveJsonModule": true,
"strictNullChecks": true
},
"typeAcquisition": { "include": ["jest"] },
}
10 changes: 10 additions & 0 deletions subgraph-query/wrapper/assemblyscript/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: subgraph-query
jobs:
cases:
steps:
- uri: fs/build
method: subgraphQuery
input:
subgraphAuthor: ensdomains
subgraphName: ens
query: "{\ndomains(first: 5) {\nid\nname\nlabelName\nlabelhash\n}\n}"
Loading