Skip to content

Commit

Permalink
Add a test that demonstrates client-only virtual resolvers.
Browse files Browse the repository at this point in the history
Inspired by issue #4731.
  • Loading branch information
benjamn committed Apr 29, 2019
1 parent aa403a8 commit a87d28b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/apollo-client/src/__tests__/local-state/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,49 @@ describe('Force local resolvers', () => {
});
},
);

it('should allow client-only virtual resolvers (#4731)', function() {
const query = gql`
query UserData {
userData @client {
firstName
lastName
fullName
}
}
`;

const client = new ApolloClient({
cache: new InMemoryCache(),
resolvers: {
Query: {
userData() {
return {
__typename: 'User',
firstName: 'Ben',
lastName: 'Newman',
};
},
},
User: {
fullName(data) {
return data.firstName + ' ' + data.lastName;
},
},
},
});

return client.query({ query }).then(result => {
expect(result.data).toEqual({
userData: {
__typename: 'User',
firstName: 'Ben',
lastName: 'Newman',
fullName: 'Ben Newman',
},
});
});
});
});

describe('Async resolvers', () => {
Expand Down

0 comments on commit a87d28b

Please sign in to comment.