diff --git a/CHANGELOG.md b/CHANGELOG.md index 08cff2eee0..eb898192bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Web3API 0.0.1-prealpha.34 +## Bugs +* `@web3api/schema-bind`: Fix TypeScript enum bindings. +* `@web3api/graph-node-plugin-js`: Fix mismatched schema. + # Web3API 0.0.1-prealpha.33 ## Bugs * `@web3api/schema-bind`: Fixed plugin code generation oversight. Should be using `null` instead of `undefined`. diff --git a/VERSION b/VERSION index cd26a18ba1..fd13539e0f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.1-prealpha.33 \ No newline at end of file +0.0.1-prealpha.34 \ No newline at end of file diff --git a/packages/js/plugins/graph-node/schema.graphql b/packages/js/plugins/graph-node/schema.graphql index fbe8b4d445..84cfcc4659 100644 --- a/packages/js/plugins/graph-node/schema.graphql +++ b/packages/js/plugins/graph-node/schema.graphql @@ -1,8 +1,7 @@ type Query { querySubgraph( - subgraphId: String! + subgraphAuthor: String! + subgraphName: String! query: String! - ): String! """JSON!""" - """TODO: support JSON type as base type?""" - """I think this would be helpful for dynamic data""" + ): String! } diff --git a/packages/js/plugins/graph-node/src/manifest.ts b/packages/js/plugins/graph-node/src/manifest.ts index ca2cbeaeb4..ccb570ab91 100644 --- a/packages/js/plugins/graph-node/src/manifest.ts +++ b/packages/js/plugins/graph-node/src/manifest.ts @@ -6,9 +6,11 @@ export const manifest: PluginPackageManifest = { schema: ` type Query { querySubgraph( - subgraphId: String! + subgraphAuthor: String! + subgraphName: String! query: String! ): String! -}`, +} +`, implements: [], }; diff --git a/packages/schema/bind/src/bindings/plugin-ts/templates/types-ts.mustache b/packages/schema/bind/src/bindings/plugin-ts/templates/types-ts.mustache index 3c96711ccd..324356a397 100644 --- a/packages/schema/bind/src/bindings/plugin-ts/templates/types-ts.mustache +++ b/packages/schema/bind/src/bindings/plugin-ts/templates/types-ts.mustache @@ -28,12 +28,19 @@ export interface {{type}} { {{/objectTypes}} {{#enumTypes}} -export enum {{type}} { +enum {{type}}Enum { {{#constants}} {{.}}, {{/constants}} } +type {{type}}String = + {{#constants}} + | "{{.}}" + {{/constants}} + +export type {{type}} = {{type}}Enum | {{type}}String; + {{/enumTypes}} /// Imported Objects START /// diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts index 1329c15493..aa6d977eea 100644 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts +++ b/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts @@ -60,11 +60,17 @@ export interface AnotherType { circular?: Types.CustomType | null; } -export enum CustomEnum { +enum CustomEnumEnum { STRING, BYTES, } +type CustomEnumString = + | "STRING" + | "BYTES" + +export type CustomEnum = CustomEnumEnum | CustomEnumString; + /// Imported Objects START /// /* URI: "testimport.uri.eth" */