Skip to content

Commit ddde6d3

Browse files
authored
Merge pull request #20 from lirown/oriw-fix-old-gql-versions
load GraphQLCustomDirective with fallback path
2 parents 9bcf31e + e3f5501 commit ddde6d3

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

src/custom.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ function resolveMiddlewareWrapper(resolve = defaultResolveFn, directives = {}) {
9999
);
100100
defer.catch(e =>
101101
resolveWithDirective(
102+
/* istanbul ignore next */
102103
() => Promise.reject(e),
103104
source,
104105
directive,

src/directiveLocation.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Resolve DirectiveLocation with fallback due to graphql breacking changes of module location
3+
*/
4+
let DirectiveLocation;
5+
try {
6+
DirectiveLocation = require('graphql/language/directiveLocation')
7+
} catch (e) {
8+
/* istanbul ignore next */
9+
DirectiveLocation = require('graphql/type/directives')
10+
}
11+
12+
module.exports = DirectiveLocation

src/directives/currency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {GraphQLString} from 'graphql';
2-
import {DirectiveLocation} from 'graphql/language/directiveLocation';
2+
import {DirectiveLocation} from '../directiveLocation';
33
import {GraphQLCustomDirective} from '../custom';
44

55
import numeral from 'numeral';

src/directives/date.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {GraphQLString, GraphQLBoolean} from 'graphql';
2-
import {DirectiveLocation} from 'graphql/language/directiveLocation';
2+
import {DirectiveLocation} from '../directiveLocation';
33
import {GraphQLCustomDirective} from '../custom';
44
import {_} from 'lodash';
55

src/directives/number.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {GraphQLString} from 'graphql';
2-
import {DirectiveLocation} from 'graphql/language/directiveLocation';
2+
import {DirectiveLocation} from '../directiveLocation';
33
import {GraphQLCustomDirective} from '../custom';
44

55
import numeral from 'numeral';

src/directives/string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {DirectiveLocation} from 'graphql/language/directiveLocation';
1+
import {DirectiveLocation} from '../directiveLocation';
22
import {GraphQLString, GraphQLNonNull} from 'graphql';
33
import {GraphQLCustomDirective} from '../custom';
44

0 commit comments

Comments
 (0)