Skip to content

GraphQL SnippetBlob should expose unaltered text content

Summary

When accessing snippets through GraphQL, I want to access unaltered text content of the snippet blob the same way as I can through the REST endpoint

Steps to reproduce

  1. Go to https://gitlab.com/-/graphql-explorer
  2. Enter the following query
    {
      snippets(ids: "gid://gitlab/ProjectSnippet/1962251"){
        nodes {
          title
          webUrl
          blobs {
            nodes {
              name
              plainData
            }
          }
        }
      }
    }

Example Project

https://gitlab.com/gitlab-org/gitter/webapp/-/snippets

What is the current bug behavior?

plainData returns the snippet with all HTML highligting elements included

<span id=\"LC1\" class=\"line\" lang=\"javascript\"><span class=\"dl\">\"</span><span class=\"s2\">use strict</span><span class=\"dl\">\"</span><span class=\"p\">;</span></span>\n<span id=\"LC2\" class=\"line\" lang=\"javascript\"></span>\n<span id=\"LC3\" class=\"line\" lang=\"javascript\"><span class=\"kd\">function</span> <span class=\"nx\">_interopDefault</span><span class=\"p\">(</span><span class=\"nx\">e</span><span class=\"p\">)</span></span>\n<span id=\"LC4\" class=\"line\" lang=\"javascript\"><span class=\"p\">{</span></span>\n<span id=\"LC5\" class=\"line\" lang=\"javascript\">\t<span class=\"k\">return</span> <span class=\"nx\">e</span> <span class=\"o\">&amp;&amp;</span> <span class=\"dl\">\"</span><span class=\"s2\">object</span><span class=\"dl\">\"</span> <span class=\"o\">==</span> <span class=\"k\">typeof</span> <span class=\"nx\">e</span> <span class=\"o\">&amp;&amp;</span> <span class=\"dl\">\"</span><span class=\"s2\">default</span><span class=\"dl\">\"</span> <span class=\"k\">in</span> <span class=\"nx\">e</span> <span class=\"p\">?</span> <span class=\"nx\">e</span><span class=\"p\">.</span><span class=\"k\">default</span> <span class=\"p\">:</span> <span class=\"nx\">e</span></span>\n<span id=\"LC6\" class=\"line\" lang=\"javascript\"><span class=\"p\">}</span></span>\n<span id=\"LC7\" class=\"line\" lang=\"javascript\"><span class=\"nb\">Object</span><span class=\"p\">.</span><span class=\"nx\">defineProperty</span><span class=\"p\">(</span><span class=\"nx\">exports</span><span class=\"p\">,</span> <span class=\"dl\">\"</span><span class=\"s2\">__esModule</span><span class=\"dl\">\"</span><span class=\"p

What is the expected correct behavior?

I would expect to have a field where I can access the unaltered content of the file

"use strict";

function _interopDefault(e)
{
	return e && "object" == typeof e && "default" in e ? e.default : e
}
Object.defineProperty(exports, "__esModule",
{
	value: !0
});
var Ky = _interopDefault(require("ky-universal")),
	FormData = _interopDefault(require("form-data")),
	xcase = require("xcase"),
	queryString = require("query-string"),
	Li = _interopDefault(require("li")),
	extendStatics = function (e, t)
	{
		return (extendStatics = Object.setPrototypeOf ||
			{
				__proto__: []
			}
			instanceof Array && function (e, t)
			{
				e.__proto__ = t
			} || function (e, t)
			{
				for (var r in t) t.hasOwnProperty(r) && (e[r] = t[r])
			})(e, t)
	};

Relevant logs and/or screenshots

Possible fixes