UNPKG

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