Skip to content

Commit

Permalink
build crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkistlt committed Jan 21, 2019
1 parent 8fac90c commit fb1c0bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
GraphQLID,
} from 'graphql';
import {
GraphQLDateTime
GraphQLDateTime,
} from 'graphql-iso-date';

const possibleGraphQLClasses = {
GraphQLObjectType,
GraphQLInputObjectType,
Expand Down Expand Up @@ -155,7 +156,7 @@ function createType(args) {
const oldFields = resultingGraphQLOptions.fields;
resultingGraphQLOptions.fields = () => Object.assign(
{},
oldFields(),
oldFields(),
{ [key]: val },
);
};
Expand Down
17 changes: 7 additions & 10 deletions tools/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint-disable array-callback-return */
/* eslint-disable no-underscore-dangle */
/* eslint-disable import/prefer-default-export */

/**
* @summary
* Get rid of thunks in a given GraphQL type.
Expand All @@ -7,21 +11,14 @@ export const getRidOfThunks = (graphQLType) => {
// Copy object
const res = Object.assign({}, graphQLType);

// Retrieve the fields
res._typeConfig.fields = res._typeConfig.fields();

// For each field
Object.keys(res._typeConfig.fields).map((field) => {
Object.keys(res).map((field) => {
// If field is a thunk
if ((typeof res._typeConfig.fields[field]) === 'function') {
if ((typeof res[field]) === 'function') {
// Execute thunk and assign result to the field
res._typeConfig.fields[field] = getRidOfThunks(res._typeConfig);
res[field] = getRidOfThunks(res[field]);
}
});

return res;
};

export default {
getRidOfThunks,
};

0 comments on commit fb1c0bf

Please sign in to comment.