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

Mapping types #14

Open
craigspaeth opened this issue Dec 21, 2016 · 1 comment
Open

Mapping types #14

craigspaeth opened this issue Dec 21, 2016 · 1 comment
Labels

Comments

@craigspaeth
Copy link
Collaborator

craigspaeth commented Dec 21, 2016

Types that map well

GraphQL Joi
GraphQLInt number().integer()
GraphQLFloat number()
GraphQLString string()
GraphQLBoolean boolean()
GraphQLObjectType object()
GraphQLInputObjectType object()
GraphQLNonNull a.required()
GraphQLList array.items(a, b, c)

Types that don't map well

GraphQL Joi
GraphQLID string().guid()
GraphQLInterfaceType alternatives(a, b)
GraphQLUnionType alternatives(a, b)
GraphQLEnumType ?

We can potentially specify these in the meta extensions e.g. string().meta({ type: 'id' }), alternatives(a, b).meta({ type: 'interface|union' }), object({ red: 1, green: 2 }).meta({ type: 'enum' }).

Or we can use custom Joi extensions, e.g. string().id(), interface(a, b), union(a, b), enum({ red: 1, green: 2 }).

The advantage of the former is we can easily leverage the extra validation from existing Joi types, the latter is more obvious how it maps to GraphQL.

@craigspaeth
Copy link
Collaborator Author

craigspaeth commented Dec 30, 2016

FWIW right now we use union type in the case of array and alternatives and ignore the rest of the types that don't map well... that might be okay for now.

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

No branches or pull requests

1 participant