Skip to content

Polywrap Manifest: Improve imports #1920

Description

@krisbitney

Importing Wraps

Importing wraps is done within all projects that integrate polywrap: apps, plugins, wraps

Today's Devexp


polywrap.graphql

#import { function, Type } into Name from "global-uri"
#import ...
...

polywrap.yaml

format: "latest"
project:
    name: i-use-polywrap
    type: project/type
source:
    ...
    schema: ./polywrap.graphql

    # If the developer wanted to have
    # import stored locally, which is nice
    # for development, they'd need
    # this...
    # Not very intuitive.
    import_abis:
        - uri: "global-uri"
          abi: "local-uri"

Tomorrow's Devexp


polywrap.json

{
    "name": "i-love-polywrap",
    "version": "1.0.0",
    "type": "wrap/rust",
    "schema": "./polywrap.graphql",
    "sources": [
      "./src"
    ],
    "imports": {
        "Name": {
            "uri": "globbal-uri",
            "functions": ["function"]
            "types": ["Type"]
        },
        "Ethers": "wrapscan.io/polywrap/ethers@1.2",
        "Custom": "./imports/Custom/polywrap.graphql"
    }
}

polywrap.graphql

type Module {
    myCode(
        obj1: Object!
        obj2: Ethers_Object
    ): String!
}

type Object {
    prop: Name_Object
}

How do we get here, seamlessly?

Us:

It looks like your project is using an
older version of Polywrap.

Please run:
$polywrap migrate

User:

$polywrap migrate
(y/n) Polywrap project files will manipulated: y_
[.] Begin migration.
[.] Finding project format...
[=] Project Format: "0.5.0"
[.] Loading project files...
[=] Loaded: "polywrap.yaml"
[=] Loaded: "polywrap.graphql"
[=] Loaded: "polywrap.deploy.yaml"
[=] Loaded: "URI.txt"
[.] Migrating from 0.5.0 to 0.6.0...
[=] "name": "i-love-polywrap"
[=] "version": "1.0.0"
[=] "type": "wrap/rust"
[=] "schema": "./polywrap.graphql"
[=] "imports": {
[=]   "Name": "..."
[=]   "Ethers": "..."
[=]   "Custom": "..."
[=] }
[.] Modifying project files...
[=] create: ./polywrap.json
[=] rewrite: ./polywrap.graphql
[=] delete: ./polywrap.yaml
[.] Migration complete.

Result:

GOTO tomorrows-devexp

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions