Replies: 1 comment 3 replies
-
@aszenz You certainly could use your operations for internal use. But, I can't help but think this is a bad idea, unless you're only talking about a handful of highly optimized pages for a high-traffic application. In general, the tech debt created from something like this is going to be a net negative and something you regret doing. That said, there are many ways to approach this. Firstly, operations (queries and mutations) in GraphQLite are just methods of a "controller". Instantiate the "controller" class and call the operation method, pass the input type object, or whatever fields to the method. From there you have the response data. The relations will be available, just like a GraphQL request when building out a query. You'll just use them within PHP to make method calls. If, for some reason, you want an array response of structured data, like you'd get from an actual HTTP response, just mock a request object and pass it into the GraphQLite middleware. As for the HTML rendering. I have no idea how you would plan on managing this, in additional to a frontend implementation. There are obviously ways of doing it, but it's not going to be ideal, especially if you're using a component architecture framework, like React, Vue, Angular, etc. |
Beta Was this translation helpful? Give feedback.
-
While building server side rendered pages, it is faster to preload data from the api and use it in html templates.
Is there a way to pass a graphql query server side and get data, that can then be used for building a view.
Beta Was this translation helpful? Give feedback.
All reactions