Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for interfaces, part 4: getter methods
Right now, if you make a query like `{ myInterface { field } }`, you have to type-switch on all the possible implementations of `myInterface` to get at `field`. Now, we generate getter-methods (e.g. `GetField`), to make that access easier. Of course this only applies to shared fields (which for now are the only ones, but once we support fragments will no longer be). This also includes a small change to the way we generate type-names for interfaces: we no longer include the name of the concrete type in the interface we propagate forward, so we generate `MyInterfaceMyFieldMyType`, not `MyInterfaceMyImplMyFieldMyType`, in the case where you have an interface `MyInterface` implemented by `MyImpl` (and maybe other types) with field `myField: MyType`. This is necessary so the getter method returns a well-defined type, and also probably convenient for calling code. It will have to get a little bit more complicated once we support fragments, where you could have two implementing types with identically-named fields of different types, but I think it'll be easiest to figure out how to deal with that when implementing fragments. While I was in the area, I added to the interface doc-comment a list of the implementations. (In GraphQL, we're guaranteed to know them all assuming our schema is up to date.) Issue: #8 Test plan: make check Reviewers: marksandstrom, adam, miguel
- Loading branch information