Skip to content

Instantly share code, notes, and snippets.

@Samuell1
Last active June 5, 2018 12:56
Show Gist options
  • Save Samuell1/4b1a910fa4340a295de2abcdf7845d68 to your computer and use it in GitHub Desktop.
Save Samuell1/4b1a910fa4340a295de2abcdf7845d68 to your computer and use it in GitHub Desktop.
Autoload *.gql / *.graphql files
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