Skip to content

Feature Request/Unexpected behaviour: Graphql handlers just return string ids instead of relationships #99

@phryneas

Description

@phryneas

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:

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
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions