Skip to main content
In addition to its REST and Local APIs, FrogBot ships with a fully featured and extensible GraphQL API. The GraphQL API is served at /api/graphql once you add its route files (see Enable GraphQL). You can customize this URL by specifying routes in your FrogBot config. The labels you provide for your Collections are used to name the GraphQL types that are created to correspond to your config. Special characters and spaces are removed.

GraphQL Clients

You can use any GraphQL client with FrogBot’s GraphQL endpoint. Here are a few popular packages:

GraphQL Options

At the top of your FrogBot Config you can define all the options to manage GraphQL.

Collections

Everything that can be done to a Collection via the REST or Local API can be done with GraphQL (outside of uploading files, which is REST-only). If you have a collection as follows:
FrogBot will automatically open up the following queries: And the following mutations:

GraphQL Playground

Once you add the playground route (see Enable GraphQL), GraphQL Playground is available in development and disabled in production. You can enable it in production by passing graphQL.disablePlaygroundInProduction a false setting in the main FrogBot Config. You can even log in using the login[collection-singular-label-here] mutation to use the Playground as an authenticated user.
To see more regarding how the above queries and mutations are used, visit your GraphQL playground (by default at ${SERVER_URL}/api/graphql-playground) while your server is running. There, you can use the “Schema” and “Docs” buttons on the right to see a ton of detail about how GraphQL operates within FrogBot.

Custom Validation Rules

You can add custom validation rules to your GraphQL API by defining a validationRules function in your FrogBot Config. This function should return an array of Validation Rules that will be applied to all incoming queries and mutations.
Pass graphQL to buildConfig in your FrogBot config.

Query complexity limits

FrogBot comes with a built-in query complexity limiter to prevent abusive queries from slowing down your server.

Field complexity

You can define custom complexity for relationship, upload and join type fields. This is useful if you want to assign a higher complexity to a field that is more expensive to resolve. This can help prevent users from running queries that are too complex.