me-me
me-me

Reputation: 5819

Concat graphql fields in query

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 ?

Upvotes: 7

Views: 6624

Answers (1)

David Maze
David Maze

Reputation: 158908

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.

Upvotes: 9

Related Questions