-
-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Labels
Description
I just noticed that over in #96 while adding tests.
If I were to add a second model "Post" with a oneOf
relationship "author" to "User", that would still be output as String
instead of referencing the User
type, which would be expected of a graphql api.
This is not a problem of my other PR, but a conceptual problem with toHandlers
. It would probably have to be part of Factory
instead of being part of Model
, to handle these spanning relationships and quite some additional work on getGraphQLType
, which is very simple right now:
data/src/model/generateGraphQLHandlers.ts
Lines 35 to 45 in f8da857
export function getGraphQLType(value: any) { | |
const resolvedValue = typeof value === 'function' ? value() : value | |
switch (resolvedValue.constructor.name) { | |
case 'Number': | |
return GraphQLInt | |
case 'Boolean': | |
return GraphQLBoolean | |
default: | |
return GraphQLString | |
} | |
} |
kettanaito and tafuri-m