How to use the @graphql-box/helpers.addChildField function in @graphql-box/helpers

To help you get started, we’ve selected a few @graphql-box/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badbatch / graphql-box / packages / request-parser / src / main / index.ts View on Github external
private _addFieldToNode(node: FieldNode | InlineFragmentNode, key: string): void {
    if (!hasChildFields(node, key)) {
      const mockAST = parse(`{${key}}`);
      const queryNode = getOperationDefinitions(mockAST, QUERY)[0];
      const fieldsAndTypeNames = getChildFields(queryNode, key);
      if (!fieldsAndTypeNames) return;

      const { fieldNode } = fieldsAndTypeNames[0];
      addChildField(node, fieldNode, this._schema, key);
    }
  }