Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Transformer should uses getFragmentDependenciesForAST
- Loading branch information
Showing
10 changed files
with
130 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
7 changes: 7 additions & 0 deletions
7
project-fixtures/transformation-global-fag-prj/fragment-leaf.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import gql from './tag'; | ||
|
||
const fragmentLeaf = gql` | ||
fragment FragmentLeaf on Query { | ||
hello | ||
} | ||
`; |
8 changes: 8 additions & 0 deletions
8
project-fixtures/transformation-global-fag-prj/fragment-node.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import gql from './tag'; | ||
|
||
const fragmentNode = gql` | ||
fragment FragmentNode on Query { | ||
bye | ||
...FragmentLeaf | ||
} | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import gql from './tag'; | ||
import { fragmentNode } from './fragment-node'; | ||
|
||
const query = gql` | ||
query MyQuery { | ||
__typename | ||
...FragmentNode | ||
} | ||
`; | ||
|
||
console.log(JSON.stringify(query, null, 2)); |
4 changes: 4 additions & 0 deletions
4
project-fixtures/transformation-global-fag-prj/schema.graphql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type Query { | ||
hello: String! | ||
bye: String! | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default function gql(literals: TemplateStringsArray, ...args: unknown[]) { | ||
// dummy impl | ||
return ''; | ||
} |
16 changes: 16 additions & 0 deletions
16
project-fixtures/transformation-global-fag-prj/tsconfig.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2015", | ||
"module": "commonjs", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"plugins": [ | ||
{ | ||
"name": "ts-graphql-plugin", | ||
"tag": "gql", | ||
"schema": "schema.graphql", | ||
"enabledGlobalFragments": true | ||
} | ||
] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
project-fixtures/transformation-global-fag-prj/webpack.config.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const path = require('path'); | ||
|
||
const TsGraphQLPlugin = require('../../webpack'); | ||
|
||
const tsgqlPlugin = new TsGraphQLPlugin({ tsconfigPath: __dirname }); | ||
|
||
module.exports = { | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
entry: { | ||
main: path.resolve(__dirname, 'query.ts'), | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
loader: 'ts-loader', | ||
options: { | ||
transpileOnly: true, | ||
getCustomTransformers: () => ({ | ||
before: [tsgqlPlugin.getTransformer()], | ||
}), | ||
}, | ||
}, | ||
], | ||
}, | ||
plugins: [tsgqlPlugin], | ||
devtool: false, | ||
}; |
This file contains 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