Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concat graphql fields in query

Tags:

graphql

gatsby

Is there a way to concat two string values in a gatsby graphql query.

Example:

  query myQuery($uid: String!) {
    page: prismicBlock(uid: { eq: $uid }) {
      uid
      data {
        body {
          __typename
          ... on PrismicBlockBodySlice {
            slice_type
            primary {
              valueA
              valueB
            }
          }
       }
     }
   }
}

Is there way to concat valueA and valueB into one value ?

like image 719
me-me Avatar asked Jul 28 '26 23:07

me-me


1 Answers

No. GraphQL doesn't have any sort of value-manipulation functions; even the "eq" syntax you show in your query is application-specific.

If you had full control over the server and its implementation, and you thought this was an operation that would be performed frequently, you could write a custom valuesAandB field whose resolver function concatenated the two. Usually you'd just wind up doing this on the client side, though.

like image 195
David Maze Avatar answered Aug 01 '26 09:08

David Maze