buildASTSchema.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { DocumentNode } from '../language/ast';
  2. import { Source } from '../language/source';
  3. import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema';
  4. import { ParseOptions } from '../language/parser';
  5. export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
  6. /**
  7. * Descriptions are defined as preceding string literals, however an older
  8. * experimental version of the SDL supported preceding comments as
  9. * descriptions. Set to true to enable this deprecated behavior.
  10. * This option is provided to ease adoption and will be removed in v16.
  11. *
  12. * Default: false
  13. */
  14. commentDescriptions?: boolean;
  15. /**
  16. * Set to true to assume the SDL is valid.
  17. *
  18. * Default: false
  19. */
  20. assumeValidSDL?: boolean;
  21. }
  22. /**
  23. * This takes the ast of a schema document produced by the parse function in
  24. * src/language/parser.js.
  25. *
  26. * If no schema definition is provided, then it will look for types named Query
  27. * and Mutation.
  28. *
  29. * Given that AST it constructs a GraphQLSchema. The resulting schema
  30. * has no resolve methods, so execution will use default resolvers.
  31. *
  32. * Accepts options as a second argument:
  33. *
  34. * - commentDescriptions:
  35. * Provide true to use preceding comments as the description.
  36. *
  37. */
  38. export function buildASTSchema(
  39. documentAST: DocumentNode,
  40. options?: BuildSchemaOptions,
  41. ): GraphQLSchema;
  42. /**
  43. * A helper function to build a GraphQLSchema directly from a source
  44. * document.
  45. */
  46. export function buildSchema(
  47. source: string | Source,
  48. options?: BuildSchemaOptions & ParseOptions,
  49. ): GraphQLSchema;