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