Skip to content

Instantly share code, notes, and snippets.

@EddiG
Last active August 31, 2018 04:59
Show Gist options
  • Save EddiG/ae0528b082ee156e0a55e453efc0b3e7 to your computer and use it in GitHub Desktop.
Save EddiG/ae0528b082ee156e0a55e453efc0b3e7 to your computer and use it in GitHub Desktop.
grep tips

Find all GraphQL queries/mutations in the directory

grep -Pzo 'gql`\s+(query|mutation)[\s\S]+?`' src/* -R | less

The output will be something like this

src/components/CurrentUser.js:gql`
  query CurrentUser {
    user {
      id
    }
  }
`
src/components/Bookmarks/DeleteBookmarkButton.js:gql`
  mutation DeleteBookmark($id: ID!) {
    deleteBookmark(id: $id) {
      id
    }
  }
`
  • -P - enables perl style regex
  • -z - replaces newline by 0 byte. Useful if you need to looking through the multiline file.
  • -o - shows only matched data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment