You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should consider allowing the usage of empty types to support polymorphism.
For example, let's say I want this:
type Action { }
type CreateAccount implements Action { }
type DeployContract implements Action {
code: Bytes!
}
Right now I'm required to do something like this:
type Action {
_: String
}
type CreateAccount implements Action {
_: String
}
type DeployContract implements Action {
code: Bytes!
}
Also note the _ placeholders propagate to generated TypeScript types.
Here is an example exception thrown when attempting to use empty types:
$ npx w3 plugin codegen
✔ Manifest loaded from ./web3api.plugin.yaml
✖ Failed to generate types: Syntax Error: Expected Name, found "}".
GraphQLError [Object]: Syntax Error: Expected Name, found "}".
at syntaxError (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/error/syntaxError.js:15:10)
at Parser.expectToken (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:1413:40)
at Parser.parseName (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:98:22)
at Parser.parseFieldDefinition (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:879:21)
at Parser.optionalMany (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:1503:28)
at Parser.parseFieldsDefinition (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:868:17)
at Parser.parseObjectTypeDefinition (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:812:23)
at Parser.parseTypeSystemDefinition (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:708:23)
at Parser.parseDefinition (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:150:23)
at Parser.many (/Users/kris/WebstormProjects/monorepo/node_modules/graphql/language/parser.js:1523:26) {
locations: [ { line: 122, column: 1 } ]
}
Interestingly, this is in the same schema and appears to build without any problems. I actually get the opposite behavior: when I try to add the _ field to the child type, I get an exception complaining about duplicate fields in the type.
type AccessKeyPermission {
_: String
}
type FullAccessPermission implements AccessKeyPermission {}
The text was updated successfully, but these errors were encountered:
We should consider allowing the usage of empty types to support polymorphism.
For example, let's say I want this:
Right now I'm required to do something like this:
Also note the
_
placeholders propagate to generated TypeScript types.Here is an example exception thrown when attempting to use empty types:
Interestingly, this is in the same schema and appears to build without any problems. I actually get the opposite behavior: when I try to add the
_
field to the child type, I get an exception complaining about duplicate fields in the type.The text was updated successfully, but these errors were encountered: