graphql: Support variable directives. (#6020)

master
Adrian Zgorzałek 2019-04-04 13:47:05 +01:00 committed by Lucas Duailibe
parent 7c9823fcba
commit 9cb50add5e
6 changed files with 68 additions and 21 deletions

View File

@ -239,6 +239,40 @@ Examples:
<div *ngIf="isRendered | async"></div>
```
- TypeScript: Support `readonly` operator ([#6027] by [@ikatyang])
<!-- prettier-ignore -->
```ts
// Input
declare const array: readonly number[];
// Output (Prettier stable)
// SyntaxError: ',' expected.
// Output (Prettier master)
declare const array: readonly number[];
```
- GraphQL: Support variable directives ([#6020] by [@adek05])
Upgrading to graphql-js 14.0 enables new GraphQL language feature - variable directives. Support for printing them is added along with the graphql-js version bump.
<!-- prettier-ignore -->
```
// Input
query Q($variable: Int @directive) {node}
// Output (Prettier stable)
query Q($variable: Int) {
node
}
// Output (Prettier master)
query Q($variable: Int @directive) {
node
}
```
- GraphQL: Support GraphQL fragment variables ([#6016] by [@adek05])
```
@ -253,17 +287,3 @@ Examples:
node
}
```
- TypeScript: Support `readonly` operator ([#6027] by [@ikatyang])
<!-- prettier-ignore -->
```ts
// Input
declare const array: readonly number[];
// Output (Prettier stable)
// SyntaxError: ',' expected.
// Output (Prettier master)
declare const array: readonly number[];
```

View File

@ -38,7 +38,7 @@
"flow-parser": "0.84.0",
"get-stream": "3.0.0",
"globby": "6.1.0",
"graphql": "0.13.2",
"graphql": "14.2.0",
"html-element-attributes": "2.0.0",
"html-styles": "1.0.0",
"html-tag-names": "1.1.2",

View File

@ -266,7 +266,8 @@ function genericPrint(path, options, print) {
path.call(print, "variable"),
": ",
path.call(print, "type"),
n.defaultValue ? concat([" = ", path.call(print, "defaultValue")]) : ""
n.defaultValue ? concat([" = ", path.call(print, "defaultValue")]) : "",
printDirectives(path, print, n)
]);
}

View File

@ -24,6 +24,14 @@ query listslong($foo: [String ], $bar: [String!], $arg: [ Int! ]!, $veryLong
ok
}
query withvariabledirective($foo: Int @directive) {
ok
}
query withvariabledirectives($foo: Int @directive @another) {
ok
}
=====================================output=====================================
query short($foo: ComplexType, $site: Site = MOBILE, $nonNull: Int!) {
hello
@ -52,5 +60,13 @@ query listslong(
ok
}
query withvariabledirective($foo: Int @directive) {
ok
}
query withvariabledirectives($foo: Int @directive @another) {
ok
}
================================================================================
`;

View File

@ -15,3 +15,11 @@ query lists($foo: [Int ], $bar: [Int!], $arg: [ Int! ]!) {
query listslong($foo: [String ], $bar: [String!], $arg: [ Int! ]!, $veryLongName: [ Int! ]) {
ok
}
query withvariabledirective($foo: Int @directive) {
ok
}
query withvariabledirectives($foo: Int @directive @another) {
ok
}

View File

@ -2701,11 +2701,12 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
graphql@0.13.2:
version "0.13.2"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.13.2.tgz#4c740ae3c222823e7004096f832e7b93b2108270"
graphql@14.2.0:
version "14.2.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.2.0.tgz#ff25813ad6d186f3975977d56bc2d2434871f3b9"
integrity sha512-dlFHRtxsL4sBy1C1e3v64IUd5ndZhAOHZ/z3Dr4Nm6+cvr9elrnz4BhMF9h9mRBBnhUCGLc4GH4xvPbKG6sUeA==
dependencies:
iterall "^1.2.1"
iterall "^1.2.2"
growly@^1.3.0:
version "1.3.0"
@ -3330,9 +3331,10 @@ istanbul-reports@^1.3.0:
dependencies:
handlebars "^4.0.3"
iterall@^1.2.1:
iterall@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2.tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7"
integrity sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==
jest-changed-files@^23.4.2:
version "23.4.2"