Skip to content

Commit

Permalink
Remove flow option experimental.const_params (#1160)
Browse files Browse the repository at this point in the history
Merges #1157

Codebases which don't enable this experiment show flow errors
  • Loading branch information
leebyron authored Dec 17, 2017
1 parent d11883e commit 68ec835
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[libs]

[options]
experimental.const_params=true

[version]
^0.61.0
3 changes: 2 additions & 1 deletion src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export function GraphQLError( // eslint-disable-line no-redeclare

let _locations;
if (positions && source) {
_locations = positions.map(pos => getLocation(source, pos));
const providedSource = source;
_locations = positions.map(pos => getLocation(providedSource, pos));
} else if (_nodes) {
_locations = _nodes.reduce((list, node) => {
if (node.loc) {
Expand Down
17 changes: 12 additions & 5 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { GraphQLList, GraphQLNonNull } from '../type/wrappers';
import { GraphQLString, GraphQLBoolean } from './scalars';
import { DirectiveLocation } from '../language/directiveLocation';
import type { GraphQLField, GraphQLType } from './definition';
import type { GraphQLField } from './definition';

export const __Schema = new GraphQLObjectType({
name: '__Schema',
Expand Down Expand Up @@ -465,11 +465,18 @@ export const introspectionTypes: $ReadOnlyArray<*> = [
__TypeKind,
];

export function isIntrospectionType(type: ?GraphQLType): boolean %checks {
export function isIntrospectionType(type: mixed): boolean %checks {
return (
isNamedType(type) &&
introspectionTypes.some(
introspectionType => introspectionType.name === type.name,
)
// Would prefer to use introspectionTypes.some(), however %checks needs
// a simple expression.
(type.name === __Schema.name ||
type.name === __Directive.name ||
type.name === __DirectiveLocation.name ||
type.name === __Type.name ||
type.name === __Field.name ||
type.name === __InputValue.name ||
type.name === __EnumValue.name ||
type.name === __TypeKind.name)
);
}
13 changes: 8 additions & 5 deletions src/type/scalars.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { GraphQLScalarType, isNamedType } from './definition';
import * as Kind from '../language/kinds';
import type { GraphQLType } from './definition';

// As per the GraphQL Spec, Integers are only treated as valid when a valid
// 32-bit signed integer, providing the broadest support across platforms.
Expand Down Expand Up @@ -145,11 +144,15 @@ export const specifiedScalarTypes: $ReadOnlyArray<*> = [
GraphQLID,
];

export function isSpecifiedScalarType(type: ?GraphQLType): boolean %checks {
export function isSpecifiedScalarType(type: mixed): boolean %checks {
return (
isNamedType(type) &&
specifiedScalarTypes.some(
specifiedScalarType => specifiedScalarType.name === type.name,
)
// Would prefer to use specifiedScalarTypes.some(), however %checks needs
// a simple expression.
(type.name === GraphQLString.name ||
type.name === GraphQLInt.name ||
type.name === GraphQLFloat.name ||
type.name === GraphQLBoolean.name ||
type.name === GraphQLID.name)
);
}

0 comments on commit 68ec835

Please sign in to comment.