Transform GraphQL source files with ReactNative
npm install react-native-graphql-transformer
Seamlessly use GraphQL files with react-native >= 0.45
This package is inspired by the
react-native-typescript-transform
repository.
Use .gqlor .graphql files with React Native packager for better readability
and separation of concerns.
Exemple of a .gql file with import statement:
``gql
#import "fragments/BasePost.gql"
query PostListItemQuery($id: ID) {
Post(id: $id) {
...BasePost
}
}
`
yarn add -D react-native-graphql-transformer
Add this to your rn-cli.config.js (make one if you don't have one already):
`js
const { getDefaultConfig } = require('metro-config');
module.exports = (async () => {
const { resolver: { sourceExts } } = await getDefaultConfig();
return {
transformer: {
babelTransformerPath: require.resolve('@bam.tech/react-native-graphql-transformer'),
},
resolver: {
sourceExts: [...sourceExts, 'gql', 'graphql'],
},
};
})();
``
|
Thomas Pucci
π» π π‘ |
TychoTa
π» |
ClΓ©ment Taboulot
π» |
arolson101
π‘ |
ajubin
π» |
Gerard de Brieder
π |
mike castleman
π |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
MIT