Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. // those 2 abstract of the same library are supposed to do the exact same thing, but are written totally differently
  2. // because no one cared about restricting the way you should use their public API.
  3. // because there's no real public API, because JS.
  4.  
  5. const hasSubscriptionOperation = ({ query: { definitions } }) => {
  6. return definitions.some(
  7. ({ kind, operation }) =>
  8. kind === 'OperationDefinition' && operation === 'subscription'
  9. )
  10. }
  11.  
  12. // VS
  13.  
  14. import { getMainDefinition } from 'apollo-utilities';
  15. const subscription = ({ query }) => {
  16. const { kind, operation } = getMainDefinition(query);
  17. return kind === 'OperationDefinition' && operation === 'subscription';
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement