Skip to content

Instantly share code, notes, and snippets.

@Faliszek
Last active November 11, 2020 14:19
Show Gist options
  • Save Faliszek/d66449c8a6837a013e59143b5f92df0f to your computer and use it in GitHub Desktop.
Save Faliszek/d66449c8a6837a013e59143b5f92df0f to your computer and use it in GitHub Desktop.
#!/bin/bash
: '
To use snowpack we want purge all /require() from our code
unfortunately the graphql-ppx adding gql tag by require
require("apollo/client").gql so we must get rid of it
1. We store our mutations and queries in /queries and /mutations folders
2. We add graphql-tag import and remove require
'
MUT='/mutations/'
QUE='/queries/'
for i; do
FILE_NAME=$i
if [[ "$FILE_NAME" == *"$MUT"* || "$FILE_NAME" == *"$QUE"* ]]; then
sed -i '' '1s/^/import gql from "graphql-tag";\'$'\n/g' $FILE_NAME
sed -i '' 's/require("@apollo\/client").//' $FILE_NAME
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment