How to use the relay-compiler/lib/ASTConvert.convertASTDocuments function in relay-compiler

To help you get started, weโ€™ve selected a few relay-compiler 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 gatsbyjs / gatsby / packages / gatsby / src / internal-plugins / query-runner / query-compiler.js View on Github external
this.reportError(graphqlValidationError(errors, filePath))
        return compiledNodes
      }

      documents.push(doc)
      doc.definitions.forEach((def: any) => {
        const name: string = def.name.value
        namePathMap.set(name, filePath)
        nameDefMap.set(name, def)
      })
    }

    let compilerContext = new GraphQLCompilerContext(this.schema)
    try {
      compilerContext = compilerContext.addAll(
        ASTConvert.convertASTDocuments(
          this.schema,
          documents,
          validationRules,
          RelayParser.transform.bind(RelayParser)
        )
      )
    } catch (error) {
      this.reportError(graphqlError(namePathMap, nameDefMap, error))
      return compiledNodes
    }

    // relay-compiler v1.5.0 added "StripUnusedVariablesTransform" to
    // printTransforms. Unfortunately it currently doesn't detect variables
    // in input objects widely used in gatsby, and therefore removing
    // variable declaration from queries.
    // As a temporary workaround remove that transform by slicing printTransforms.