How to use the apollo-client.printAST function in apollo-client

To help you get started, we’ve selected a few apollo-client 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 jaydenseric / apollo-upload-client / src / network-interface.js View on Github external
fetchFromRemoteEndpoint({ request, options }) {
    // Continue if uploads are possible
    if (typeof FormData !== 'undefined') {
      // Extract any files from the request variables
      const files = extractFiles(request.variables, 'variables')

      // Continue if there are files to upload
      if (files.length) {
        // Convert query AST to string for transport
        request.query = printAST(request.query)

        // Construct a multipart form
        const formData = new FormData()
        formData.append('operations', JSON.stringify(request))
        files.forEach(({ path, file }) => formData.append(path, file))

        // Send request
        return fetch(this._uri, {
          method: 'POST',
          body: formData,
          ...options
        })
      }
    }

    // Standard fetch method fallback
github HarenBroog / ember-graph-data / addon / apollo-client / network-interface.js View on Github external
fetchFromRemoteEndpoint({ request, options }) {
    // Continue if uploads are possible
    if (typeof FormData !== 'undefined') {
      // Extract any files from the request variables

      const files = extractFiles(request.variables, 'variables')

      // Continue if there are files to upload
      if (files.length) {
        // Convert query AST to string for transport
        request.query = printAST(request.query)

        // Construct a multipart form
        const formData = new FormData()
        // formData.append('operations', JSON.stringify(request))
        formData.append('query', request.query)
        formData.append('operationName', request.operationName)
        files.forEach(({ path, file }) => {
          formData.append(path, file)
          request.variables[path.replace("variables.", "")] = path
        })
        formData.append('variables', JSON.stringify(request.variables))

        // Send request
        return fetch(this._uri, {
          method: 'POST',
          body: formData,
github mstn / apollo-local-network-interface / src / LocalNetworkInterface.ts View on Github external
public query(request: Request): Promise {
    const { query, variables } = request;
    return graphql(
      this.schema,
      printAST(query),
      null,
      null,
      variables,
    );
  }
  public getSchema(): GraphQLSchema {
github jaydenseric / apollo-upload-client / src / batched-network-interface.js View on Github external
requests.forEach(request => {
          request.query = printAST(request.query)
        })