Skip to content

Commit d836051

Browse files
author
Kumar Harsh
committed
fix(syntax): fix blockstring description syntax, add some sample files
1 parent e52efb0 commit d836051

File tree

6 files changed

+153
-17
lines changed

6 files changed

+153
-17
lines changed

syntaxes/graphql.json

+13-17
Original file line numberDiff line numberDiff line change
@@ -202,31 +202,27 @@
202202
},
203203
"graphql-description-singleline": {
204204
"comment": "In new graphql spec 0.12.0, the description have to be specified as doc-strings or single-line text in double quotes",
205-
"name": "graphql.description",
205+
"name": "graphql.description.SINGLELINE",
206206
"match": "^\\s*(\"(?:\"\")?)([^\"].*)(\"(?:\"\")?)$",
207207
"captures": {
208-
"1": { "name": "comment.quoted.double.graphql.begin" },
209-
"2": { "name": "comment.description.graphql" },
210-
"3": { "name": "comment.quoted.double.graphql.end" }
208+
"1": { "name": "punctuation.definition.string.graphql.begin" },
209+
"2": { "name": "string.description.graphql" },
210+
"3": { "name": "punctuation.definition.string.graphql.end" }
211211
}
212212
},
213213
"graphql-description-docstring": {
214214
"comment": "In new graphql spec 0.12.0, the description have to be specified as doc-strings or single-line text in double quotes",
215-
"name": "graphql.description",
216-
"begin": "(\"\"\")(?:$|(.*))",
215+
"name": "string.block.description.graphql.DOCSTRING",
216+
"begin": "(\"\"\")(?:((?!\"\"\").)*|\\Z)",
217217
"beginCaptures": {
218-
"1": { "name": "comment.quoted.double.graphql.begin" },
219-
"2": { "name": "comment.block.description.graphql" }
218+
"1": { "name": "punctuation.definition.string.graphql.begin" }
220219
},
221-
"end": "^\\s*(\"\"\")$",
220+
"end": "(\"\"\")$",
222221
"endCaptures": {
223-
"1": { "name": "comment.quoted.double.graphql.end" }
222+
"1": { "name": "punctuation.definition.string.graphql.end" }
224223
},
225224
"patterns": [
226-
{
227-
"name": "comment.block.description.graphql",
228-
"match": "^\\s*.*$"
229-
}
225+
{ "include": "#graphql-string-content" }
230226
]
231227
},
232228
"graphql-variable-definitions": {
@@ -511,11 +507,11 @@
511507
"end": "\\s*+(?:((\"))|(\n))",
512508
"beginCaptures": {
513509
"1": { "name": "string.quoted.double.graphql" },
514-
"2": { "name": "punctuation.definition.string.begin.graphql" }
510+
"2": { "name": "punctuation.definition.string.graphql.begin" }
515511
},
516512
"endCaptures": {
517513
"1": { "name": "string.quoted.double.graphql" },
518-
"2": { "name": "punctuation.definition.string.end.graphql" },
514+
"2": { "name": "punctuation.definition.string.graphql.end" },
519515
"3": { "name": "invalid.illegal.newline.graphql" }
520516
},
521517
"patterns": [
@@ -571,10 +567,10 @@
571567
"graphql-value":{
572568
"patterns": [
573569
{ "include": "#graphql-comment" },
574-
{ "include": "#graphql-description-docstring" },
575570
{ "include": "#graphql-variable-name" },
576571
{ "include": "#graphql-float-value" },
577572
{ "include": "#graphql-string-value" },
573+
{ "include": "#graphql-description-docstring" },
578574
{ "include": "#graphql-boolean-value" },
579575
{ "include": "#graphql-null-value" },
580576
{ "include": "#graphql-enum-value" },

test/test.gql

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
schema {
2+
query: RootSchemaQuery
3+
mutation: RootSchemaMutation
4+
}
5+
6+
"""Test comment."""
7+
enum TestEnum {
8+
CREATED
9+
}
10+
11+
"""
12+
This is a description
13+
"""
14+
type Viewer {
15+
"""blockstring description 1"""
16+
id: String!
17+
"""blockstring description 2
18+
"""
19+
name: String!
20+
"""
21+
blockstring description 2"""
22+
description: String
23+
"""
24+
blockstring description 3
25+
"""
26+
image: String
27+
"simple description"
28+
count: Int
29+
}
30+
31+
type Query {
32+
id: String
33+
viewer: Viewer
34+
}
35+
36+
query {
37+
posts(
38+
first: 1,
39+
text: "hi"
40+
contains: """once
41+
upon
42+
a time""") {
43+
id
44+
}
45+
}

test/test.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const x = gql`
2+
"""
3+
This is a description
4+
"""
5+
type Viewer {
6+
"""This is a field level description"""
7+
sid: String
8+
"This is a simple description"
9+
name: String
10+
}
11+
`;
12+
13+
export default /* GraphQL */`
14+
query Viewer {
15+
session {
16+
id
17+
isLoggedIn
18+
}
19+
}
20+
`;
21+
22+
const Query = Relay.QL`
23+
query {
24+
posts(
25+
first: 1,
26+
text: "hi"
27+
contains: """once
28+
upon
29+
a time""") {
30+
id
31+
}
32+
}
33+
`;

test/test.md

Whitespace-only changes.

test/test.re

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
let input = {|
2+
<html>
3+
<head>
4+
<title>A Simple HTML Document</title>
5+
</head>
6+
<body>
7+
<p>This is a very simple HTML document</p>
8+
<p>It only has two paragraphs</p>
9+
</body>
10+
</html>
11+
|};
12+
13+
let query = {gql|
14+
query X {
15+
a
16+
b
17+
c
18+
}
19+
|};
20+
21+
let result = Js.String.match([%re {|/<p>(.*?)<\/p>/gi|}], input);
22+
23+
switch (result) {
24+
| Some(result) => Js.Array.forEach(Js.log, result)
25+
| None => Js.log("no matches")
26+
};

test/test.vue

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!-- Example.vue -->
2+
<template>
3+
<query-renderer :environment="environment" :query="query" :variables="variables">
4+
<template slot-scope="{ props, error, retry }">
5+
<div v-if="error">{{ error.message }}</div>
6+
<div v-else-if="props">{{ props.page.name }} is great!</div>
7+
<div v-else>Loading</div>
8+
</template>
9+
</query-renderer>
10+
</template>
11+
12+
<script>
13+
import { QueryRenderer, graphql } from 'vue-relay'
14+
15+
export default {
16+
name: 'example',
17+
components: {
18+
QueryRenderer
19+
},
20+
data () {
21+
return {
22+
environment: ..., // https://facebook.github.io/relay/docs/en/relay-environment.html
23+
query: graphql`
24+
query ExampleQuery($pageID: ID!) {
25+
page(id: $pageID) {
26+
name
27+
}
28+
}
29+
`,
30+
variables: {
31+
pageID: '110798995619330'
32+
}
33+
}
34+
}
35+
}
36+
</script>

0 commit comments

Comments
 (0)