extendSchema.d.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { Maybe } from '../jsutils/Maybe';
  2. import { Location, DocumentNode, StringValueNode } from '../language/ast';
  3. import {
  4. GraphQLSchemaValidationOptions,
  5. GraphQLSchema,
  6. GraphQLSchemaNormalizedConfig,
  7. } from '../type/schema';
  8. interface Options extends GraphQLSchemaValidationOptions {
  9. /**
  10. * Descriptions are defined as preceding string literals, however an older
  11. * experimental version of the SDL supported preceding comments as
  12. * descriptions. Set to true to enable this deprecated behavior.
  13. * This option is provided to ease adoption and will be removed in v16.
  14. *
  15. * Default: false
  16. */
  17. commentDescriptions?: boolean;
  18. /**
  19. * Set to true to assume the SDL is valid.
  20. *
  21. * Default: false
  22. */
  23. assumeValidSDL?: boolean;
  24. }
  25. /**
  26. * Produces a new schema given an existing schema and a document which may
  27. * contain GraphQL type extensions and definitions. The original schema will
  28. * remain unaltered.
  29. *
  30. * Because a schema represents a graph of references, a schema cannot be
  31. * extended without effectively making an entire copy. We do not know until it's
  32. * too late if subgraphs remain unchanged.
  33. *
  34. * This algorithm copies the provided schema, applying extensions while
  35. * producing the copy. The original schema remains unaltered.
  36. *
  37. * Accepts options as a third argument:
  38. *
  39. * - commentDescriptions:
  40. * Provide true to use preceding comments as the description.
  41. *
  42. */
  43. export function extendSchema(
  44. schema: GraphQLSchema,
  45. documentAST: DocumentNode,
  46. options?: Options,
  47. ): GraphQLSchema;
  48. /**
  49. * @internal
  50. */
  51. export function extendSchemaImpl(
  52. schemaConfig: GraphQLSchemaNormalizedConfig,
  53. documentAST: DocumentNode,
  54. options?: Options,
  55. ): GraphQLSchemaNormalizedConfig;
  56. /**
  57. * Given an ast node, returns its string description.
  58. * @deprecated: provided to ease adoption and will be removed in v16.
  59. *
  60. * Accepts options as a second argument:
  61. *
  62. * - commentDescriptions:
  63. * Provide true to use preceding comments as the description.
  64. *
  65. */
  66. export function getDescription(
  67. node: { readonly description?: StringValueNode; readonly loc?: Location },
  68. options?: Maybe<{ commentDescriptions?: boolean }>,
  69. ): string | undefined;