UNPKG

1.37 kBTypeScriptView Raw
1import { Source } from '../language/source';
2
3/**
4 * Strips characters that are not significant to the validity or execution
5 * of a GraphQL document:
6 * - UnicodeBOM
7 * - WhiteSpace
8 * - LineTerminator
9 * - Comment
10 * - Comma
11 * - BlockString indentation
12 *
13 * Note: It is required to have a delimiter character between neighboring
14 * non-punctuator tokens and this function always uses single space as delimiter.
15 *
16 * It is guaranteed that both input and output documents if parsed would result
17 * in the exact same AST except for nodes location.
18 *
19 * Warning: It is guaranteed that this function will always produce stable results.
20 * However, it's not guaranteed that it will stay the same between different
21 * releases due to bugfixes or changes in the GraphQL specification.
22 *
23 * Query example:
24 *
25 * query SomeQuery($foo: String!, $bar: String) {
26 * someField(foo: $foo, bar: $bar) {
27 * a
28 * b {
29 * c
30 * d
31 * }
32 * }
33 * }
34 *
35 * Becomes:
36 *
37 * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
38 *
39 * SDL example:
40 *
41 * """
42 * Type description
43 * """
44 * type Foo {
45 * """
46 * Field description
47 * """
48 * bar: String
49 * }
50 *
51 * Becomes:
52 *
53 * """Type description""" type Foo{"""Field description""" bar:String}
54 */
55export function stripIgnoredCharacters(source: string | Source): string;