Skip to content

Commit

Permalink
Revert "feat(apollo-cache-inmemory): support custom directives (apoll…
Browse files Browse the repository at this point in the history
…ographql#2710)"

This reverts commit de38f3c.
  • Loading branch information
peggyrayzis committed Jan 30, 2018
1 parent 219078a commit cdaf3d6
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 84 deletions.
32 changes: 0 additions & 32 deletions packages/apollo-cache-inmemory/src/__tests__/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,38 +165,6 @@ describe('reading from the store', () => {
});
});

it('runs a basic query with custom directives', () => {
const query = gql`
query {
id
firstName @include(if: true)
lastName @upperCase
birthDate @dateFormat(format: "DD-MM-YYYY")
}
`;

const store = defaultNormalizedCacheFactory({
ROOT_QUERY: {
id: 'abcd',
firstName: 'James',
'lastName@upperCase': 'BOND',
'birthDate@dateFormat({"format":"DD-MM-YYYY"})': '20-05-1940',
},
});

const result = readQueryFromStore({
store,
query,
});

expect(result).toEqual({
id: 'abcd',
firstName: 'James',
lastName: 'BOND',
birthDate: '20-05-1940',
});
});

it('runs a basic query with default values for arguments', () => {
const query = gql`
query someBigQuery(
Expand Down
32 changes: 0 additions & 32 deletions packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,38 +221,6 @@ describe('writing to the store', () => {
});
});

it('properly normalizes a query with custom directives', () => {
const query = gql`
query {
id
firstName @include(if: true)
lastName @upperCase
birthDate @dateFormat(format: "DD-MM-YYYY")
}
`;

const result: any = {
id: 'abcd',
firstName: 'James',
lastName: 'BOND',
birthDate: '20-05-1940',
};

const normalized = writeQueryToStore({
result,
query,
});

expect(normalized.toObject()).toEqual({
ROOT_QUERY: {
id: 'abcd',
firstName: 'James',
'lastName@upperCase': 'BOND',
'birthDate@dateFormat({"format":"DD-MM-YYYY"})': '20-05-1940',
},
});
});

it('properly normalizes a nested object with an ID', () => {
const query = gql`
{
Expand Down
1 change: 0 additions & 1 deletion packages/apollo-client/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ Robert Simon <[email protected]>
Sondre Maere Overskaug <[email protected]>
Tim Griesser <[email protected]>
Adam Tuttle <[email protected]>
Greg Bergé <[email protected]>
3 changes: 0 additions & 3 deletions packages/apollo-utilities/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
### 1.1.1
- Fix typo in error message for invalid argument being passed to @skip or @include directives [PR#2867](https://github.com/apollographql/apollo-client/pull/2867)

### 1.1.0
- update `getStoreKeyName` to support custom directives

### 1.0.5
- package dependency updates

Expand Down
18 changes: 2 additions & 16 deletions packages/apollo-utilities/src/storeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ export type Directives = {
};
};

const KNOWN_DIRECTIVES: string[] = ['connection', 'include', 'skip'];

export function getStoreKeyName(
fieldName: string,
args?: Object,
Expand Down Expand Up @@ -199,25 +197,13 @@ export function getStoreKeyName(
}
}

let completeFieldName: string = fieldName;

if (args) {
const stringifiedArgs: string = JSON.stringify(args);
completeFieldName += `(${stringifiedArgs})`;
}

if (directives) {
Object.keys(directives).forEach(key => {
if (KNOWN_DIRECTIVES.indexOf(key) !== -1) return;
if (directives[key] && Object.keys(directives[key]).length) {
completeFieldName += `@${key}(${JSON.stringify(directives[key])})`;
} else {
completeFieldName += `@${key}`;
}
});
return `${fieldName}(${stringifiedArgs})`;
}

return completeFieldName;
return fieldName;
}

export function argumentsObjectFromField(
Expand Down

0 comments on commit cdaf3d6

Please sign in to comment.