Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/composables/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ const nodeLocationFields = {
start: ['loc', '0', 'start'],
end: ['loc', '1', 'end'],
},
graphql: {
type: ['kind'],
start: ['loc', 'start'],
end: ['loc', 'end'],
},
} as const

export function genGetNodeLocation(
Expand Down
32 changes: 32 additions & 0 deletions app/parser/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { graphqlTemplate } from './template'
import type { LanguageOption, Parser } from './index'
import type * as GraphQL from 'graphql'

// @unocss-include

const graphqlParser: Parser<typeof GraphQL, GraphQL.ParseOptions> = {
id: 'graphql',
label: 'graphql',
icon: 'i-vscode-icons:file-type-graphql',
link: 'https://graphql.org/graphql-js/',
editorLanguage: 'graphql',
options: {
configurable: true,
defaultValue: {
noLocation: false,
},
editorLanguage: 'json',
},
pkgName: 'graphql',
parse(code, options) {
return this.parse(code, options)
},
getNodeLocation: genGetNodeLocation('graphql'),
}

export const graphql: LanguageOption = {
label: 'GraphQL',
icon: 'i-vscode-icons:file-type-graphql',
parsers: [graphqlParser],
codeTemplate: graphqlTemplate,
}
3 changes: 3 additions & 0 deletions app/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { angular } from './angular'
import { astro } from './astro'
import { css } from './css'
import { custom } from './custom'
import { graphql } from './graphql'
import { html } from './html'
import { javascript } from './javascript'
import { json } from './json'
Expand Down Expand Up @@ -32,6 +33,7 @@ export type MonacoLanguage =
| 'php'
| 'solidity'
| 'astro'
| 'graphql'

export interface Parser<C = unknown, O = unknown> {
id: string
Expand Down Expand Up @@ -101,6 +103,7 @@ export const LANGUAGES = {
php,
solidity,
wxml,
graphql,
custom,
}
export type Language = keyof typeof LANGUAGES
19 changes: 19 additions & 0 deletions app/parser/template/graphql.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fragment UserFields on User {
id
name
email
}

query GetUsers {
users {
id
name
email
}
}

mutation CreateUser($name: String!, $email: String!) {
createUser(name: $name, email: $email) {
...UserFields
}
}
1 change: 1 addition & 0 deletions app/parser/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export { default as yamlTemplate } from './yaml.yaml?raw'
export { default as rustTemplate } from './rust.rs?raw'
export { default as phpTemplate } from './php.php?raw'
export { default as solidityTemplate } from './solidity.sol?raw'
export { default as graphqlTemplate } from './graphql.gql?raw'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"esprima-next": "^6.0.3",
"floating-vue": "^5.2.2",
"flow-parser": "^0.289.0",
"graphql": "^16.11.0",
"htmlparser2": "^10.0.0",
"jinx-rust": "^0.1.6",
"jsonc-eslint-parser": "^2.4.1",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

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