polywrap / wrap-cli

Used to create, build, and integrate wraps.
https://polywrap.io
MIT License
169 stars 54 forks source link

Polywrap Manifest: Improve imports #1920

Open krisbitney opened 9 months ago

krisbitney commented 9 months ago

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
krisbitney commented 9 months ago

TODO: