Skip to content

Commit

Permalink
fix: remove ?import from query, so .[ext]$ checks will pass (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 18, 2022
1 parent 237b48c commit 8213446
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 8 deletions.
23 changes: 23 additions & 0 deletions examples/graphql/package.json
@@ -0,0 +1,23 @@
{
"name": "@vitest/graphql",
"private": true,
"files": [
"dist",
"types"
],
"scripts": {
"coverage": "vitest run --coverage",
"dev": "vite",
"test": "vitest",
"test:ui": "vitest --ui"
},
"dependencies": {
"@rollup/plugin-graphql": "^1.1.0",
"graphql": "^16.3.0"
},
"devDependencies": {
"@vitest/ui": "latest",
"vite": "latest",
"vitest": "latest"
}
}
3 changes: 3 additions & 0 deletions examples/graphql/src/Fragment.gql
@@ -0,0 +1,3 @@
fragment CurrentUserFields on User {
id
}
7 changes: 7 additions & 0 deletions examples/graphql/src/Query.gql
@@ -0,0 +1,7 @@
#import "./Fragment.gql"

query Foo {
currentUser {
...CurrentUserFields
}
}
5 changes: 5 additions & 0 deletions examples/graphql/src/query.ts
@@ -0,0 +1,5 @@
import QUERY from './Query.gql'

export function getQuery() {
return QUERY
}
6 changes: 6 additions & 0 deletions examples/graphql/test/query.spec.ts
@@ -0,0 +1,6 @@
import { expect, test } from 'vitest'
import { getQuery } from '../src/query'

test('query is defined', () => {
expect(getQuery()).toBeDefined()
})
9 changes: 9 additions & 0 deletions examples/graphql/vite.config.ts
@@ -0,0 +1,9 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite'
import graphql from '@rollup/plugin-graphql'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [graphql()],
})
1 change: 1 addition & 0 deletions packages/vite-node/src/utils.ts
Expand Up @@ -19,6 +19,7 @@ export function normalizeId(id: string, base?: string): string {
.replace(/^(node|file):/, '')
.replace(/^\/+/, '/') // remove duplicate leading slashes
.replace(/[?&]v=\w+/, '?') // remove ?v= query
.replace(/\?import/, '') // remove ?import query
.replace(/\?$/, '') // remove end query mark
}

Expand Down
56 changes: 48 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8213446

Please sign in to comment.