-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for generics #8
Labels
Comments
Example of what I mean: If I write class Foo<Bar> {
let bar: Bar
let baz: String
let item: Int
func other() -> [Bar] { ... }
} And in our Schema we use: I want a schema that looks like this: interface FooBase {
baz: String!
item: Int!
}
type FooOfBoolean implements FooBase {
baz: String!
item: Int!
bar: Boolean!
other: [Boolean!]!
}
type FooOfOptionalOfFloat implements FooBase {
baz: String!
item: Int!
bar: Float
other: [Float]!
} |
This should also be compatible with our strategies for resolving subclassing: So if we also have: class SpecificFoo<T>: Foo<T> {
let specific: T?
let someData: Bool
} then our final schema should be: // Bases
interface FooBase {
baz: String!
item: Int!
}
interface SpecificFooBase {
baz: String!
item: Int!
someData: Boolean!
}
// Interface Definitions of Foo superclass
interface FooOfBoolean {
baz: String!
item: Int!
bar: Boolean!
other: [Boolean!]!
}
interface FooOfOptionalOfFloat {
baz: String!
item: Int!
bar: Float
other: [Float]!
}
// Concrete Implementations of Foo super class
type __FooOfBoolean implements FooBase, FooOfBoolean {
baz: String!
item: Int!
bar: Boolean!
other: [Boolean!]!
}
type __FooOfOptionalOfFloat implements SpecificFooBase, FooBase, FooOfOptionalOfFloat {
baz: String!
item: Int!
bar: Float
other: [Float]!
}
// Concrete Implementations of Foo subclass
type SpecificFooOfBoolean implements SpecificFooBase, FooBase, FooOfBoolean {
// Super Class
baz: String!
item: Int!
bar: Boolean!
other: [Boolean!]!
// Subclass
someData: Boolean!
specific: Boolean
}
type SpecificFooOfOptionalOfFloat implements SpecificFooBase, FooBase, FooOfOptionalOfFloat {
// Super Class
baz: String!
item: Int!
bar: Float
other: [Float]!
// Subclass
someData: Boolean!
specific: Float
} |
Or move to using this as soon as its possible: graphql/graphql-spec#190 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently Generics are not very easy to use...
The users usually have to define their own type names and more importantly. We end up creating one version per generic parameter used.
We should extract the non generic stuff and put it in an interface
The text was updated successfully, but these errors were encountered: