stripIgnoredCharacters.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { 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. * query SomeQuery($foo: String!, $bar: String) {
  25. * someField(foo: $foo, bar: $bar) {
  26. * a
  27. * b {
  28. * c
  29. * d
  30. * }
  31. * }
  32. * }
  33. *
  34. * Becomes:
  35. *
  36. * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
  37. *
  38. * SDL example:
  39. *
  40. * """
  41. * Type description
  42. * """
  43. * type Foo {
  44. * """
  45. * Field description
  46. * """
  47. * bar: String
  48. * }
  49. *
  50. * Becomes:
  51. *
  52. * """Type description""" type Foo{"""Field description""" bar:String}
  53. */
  54. export function stripIgnoredCharacters(source: string | Source): string;