Answers
- It depends on the use cases. However, GraphQL performs much better for mobile apps and web-based UI applications and is best suited for service-to-service (s2s) communications.
- Fragments should be used while sending a request from the GraphQL client when the response contains an interface or union.
- You can use a variable in a GraphQL query/mutation, as shown in the following code. This code used to modify the GraphQL request sent in step 6 of the Testing GraphQL queries and mutations section:
mutation { addStar(input: {starrableId: $repoId }) { clientMutationId }}
Here, you can see that the $repoId
variable is used. You must declare that variable in the named mutation and it can then be used in the mutation’s argument, as shown in the following code snippet:
{ "repoId": "R_kgDOHzYNwg" }