Last active
June 5, 2018 12:56
-
-
Save Samuell1/4b1a910fa4340a295de2abcdf7845d68 to your computer and use it in GitHub Desktop.
Autoload *.gql / *.graphql files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const contextQuery = require.context('./queries', true, /\.(gql|graphql)$/) | |
const query = {} | |
contextQuery.keys().forEach((filename) => { | |
const queryKey = filename.split('/').pop().replace(/.gql|.graphql/i, '') | |
query[queryKey] = contextQuery(filename) | |
}) | |
export default query |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment