Building GraphQL queries programmatically

Options

I'm new to Xano and even newer to GraphQL. There doesn't seem to be any extension for building GraphQL queries programmatically similar to, for example, this npm package.

I'd like to know if anyone has experience with custom functions for building the query string. I like to have a set of custom functions for programmatically querying REST APIs to avoid repeating myself, so I'm wondering how I could achieve this with GraphQL. Based on the npm package linked above, I imagine one way of going about it would be to build the query as an object and use a helper function to convert it into a GraphQL query. Any ideas?

Tagged:

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    No-code tools in general are not good at solving the general case ("let's make a graphql request") but can be very useful for the specific ("let's make a request to pull all the books with a search string from this library that uses graphql"). When we have worked with GQL requests from Xano in State Change office hours, we took a tokenized string manipulation approach rather than object serialization. This means you have more special cases, but its much clearer what each one does because the query template is clarifying in that regard.