Skip to content
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

Any plans for adding interface support? #11

Open
ruhnowg opened this issue Apr 11, 2018 · 2 comments
Open

Any plans for adding interface support? #11

ruhnowg opened this issue Apr 11, 2018 · 2 comments

Comments

@ruhnowg
Copy link

ruhnowg commented Apr 11, 2018

Do you currently have any plans for adding support for GraphQLInterfaceType?

@pie6k
Copy link
Collaborator

pie6k commented Apr 12, 2018

I'll add such support hopefully this or next week.

@lorefnon
Copy link
Contributor

I have a suggestion for this but that may entail a breaking change:

const IPerson = InterfaceType("IPerson", { ... })
const Person = ObjectType({ ... }) // Or ObjectType("Person", { ... })

@IPerson.Type()
@Person.Type()
class Person  {

    @IPerson.Field()
    @Person.Field()
    name: string;

    @Person.Field({type: GraphQLDate})
    dob: Date

    @IPerson.Field()
    @Person.Field()
    age() {
         return moment(this.dob).diff(moment(), 'year');
    }
}

This allows using the same implementation as a basis for multiple Object types, interface types or input types.

When implementing just an object type, this verbosity can be reduced by destructuring:

const {Type, Field} = ObjectType({... });

@Type()
class Person {
    @Field() 
    name: string;

    // ....
}

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants