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

Bump graphql dependency #25

Merged
merged 4 commits into from
Dec 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
flatten,
isEmpty,
mapValues,
omit,
omitBy,
isNull,
fromPairs,
Expand Down Expand Up @@ -108,7 +109,12 @@ const makeArrayAlternativeType = (cachedTypes, isInput, typeName, desc, items) =
return cachedTypes[typeName]
} else if (isInput) {
const children = fromPairs(flatten(items.map((item) => map(item._inner.children, (c) => [c.key, c.schema]))))
const fields = descsToFields(children)

// Strip resolvers from generated types
const fields = mapValues(descsToFields(children), (field) => {
return omit(field, 'resolve');
});

return new GraphQLInputObjectType({
name: typeName,
description: desc.description,
Expand Down Expand Up @@ -143,16 +149,16 @@ const descToArgs = (schema) => {
}

// Wraps a resolve function specifid in a Joi schema to add validation.
const validatedResolve = (schema) => (source, args, root, opts) => {
const validatedResolve = (schema) => (source, args, context, opts) => {
const desc = schema.describe()
const resolve = desc.meta && first(compact(map(desc.meta, 'resolve')))
if (args && !isEmpty(args)) {
const argsSchema = first(compact(map(desc.meta, 'args')))
const value = Joi.attempt(args, argsSchema)
return resolve(source, value, root, opts)
return resolve(source, value, context, opts)
}
if (resolve) return resolve(source, args, root, opts)
else return source && source[opts.fieldASTs[0].name.value]
if (resolve) return resolve(source, args, context, opts)
else return source && source[opts.fieldNodes[0].name.value]
}

// Convert a hash of descriptions into an object appropriate to put in a
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"graphql": "^0.7.2",
"graphql": "^0.11.7",
"lodash": "^4.13.1"
},
"peerDependencies": {
Expand Down