Skip to content

Commit

Permalink
Merge pull request #176 from apollostack/minor-refactor
Browse files Browse the repository at this point in the history
Minor refactor
  • Loading branch information
Sashko Stubailo committed May 5, 2016
2 parents bc65a15 + ebf063d commit e7c1248
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
7 changes: 0 additions & 7 deletions src/data/resultUtils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/data/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {

import {
graphQLResultHasError,
} from './resultUtils';
} from './storeUtils';

export interface NormalizedCache {
[dataId: string]: StoreObject;
Expand Down
16 changes: 15 additions & 1 deletion src/data/storeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
StringValue,
BooleanValue,
Variable,
InlineFragment,
Value,
Selection,
GraphQLResult,
} from 'graphql';


import includes = require('lodash.includes');

type ScalarValue = IntValue | FloatValue | StringValue | BooleanValue;
Expand Down Expand Up @@ -52,3 +54,15 @@ export function resultKeyNameFromField(field: Field): string {
field.alias.value :
field.name.value;
}

export function isField(selection: Selection): selection is Field {
return selection.kind === 'Field';
}

export function isInlineFragment(selection: Selection): selection is InlineFragment {
return selection.kind === 'InlineFragment';
}

export function graphQLResultHasError(result: GraphQLResult) {
return result.errors && result.errors.length;
}
12 changes: 2 additions & 10 deletions src/data/writeToStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import {
import {
storeKeyNameFromField,
resultKeyNameFromField,
isField,
isInlineFragment,
} from './storeUtils';

import {
OperationDefinition,
SelectionSet,
Selection,
FragmentDefinition,
Field,
InlineFragment,
Document,
} from 'graphql';

Expand Down Expand Up @@ -250,11 +250,3 @@ function writeFieldToStore({

store[dataId] = newStoreObj;
}

function isField(selection: Selection): selection is Field {
return selection.kind === 'Field';
}

function isInlineFragment(selection: Selection): selection is InlineFragment {
return selection.kind === 'InlineFragment';
}
2 changes: 1 addition & 1 deletion src/queries/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import {
graphQLResultHasError,
} from '../data/resultUtils';
} from '../data/storeUtils';

import {
SelectionSet,
Expand Down

0 comments on commit e7c1248

Please sign in to comment.