aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

Interfaces versus Types generation #912

Closed craicoverflow closed 3 years ago

craicoverflow commented 4 years ago

I noticed that the types generated to files by Offix Datastore are interfaces, not types. I know that there are subtle difference between the two but I wonder will this distinction become clear when they are needed in Offix.

I know that the types generated by GraphQL Code Generator are types, not interfaces.

I don't know the answer, but I think it is worth investigating which to use. Maybe this has already been discussed and concluded in Offix, in which case you can close this issue.

A couple of things you can do with types, but not with interfaces:

This article covers the differences, and actually explains when to use one over the other.

wtrocki commented 4 years ago

GraphQL code generator has different use cases as those types will be used later in various contexts and to prevent extensibility (so things will not break on your app when you extend it. We do not have such cases meaning interfaces are ok. There is a lot of work required on fix itself on codegen and project types.