Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphQL string concatenation or interpolation

Tags:

string

graphql

I'm using GitHub API v 4 to learn GraphQL. Here is a broken query to fetch blobs (files) and their text content for a given branch:

query GetTree($branch: String = "master") {
  repository(name: "blog-content", owner: "lzrski") {
    branch: ref(qualifiedName: "refs/heads/${branch}") {
      name
      target {
        ... on Commit {
          tree {
            entries {
              name
              object {
                ... on Blob {
                  isBinary
                  text
                }
              }
            }
          }
        }
      }
    }
  }
}

As you see on line 3 there is my attempt of guessing interpolation syntax, but it does not work - I leave it as an illustration of my intention.

I could provide a fully qualified name for a revision, but that doesn't seem particularly elegant. Is there any GraphQL native way of manipulating strings?

like image 883
Tad Lispy Avatar asked Sep 03 '17 10:09

Tad Lispy


1 Answers

I don't think there's anything in the GraphQL specification that specifically outlines any methods for manipulating string values within a query.

However, when utilizing GraphQL queries within an actual application, you will provide most of the arguments for your query by utilizing variables that are passed alongside your query inside your request. So rather than being done inside your query, most of your string manipulation will be done within your client code when composing the JSON that will represent your variables.

like image 125
Daniel Rearden Avatar answered Sep 22 '22 21:09

Daniel Rearden