Introduction to the GraphQL API schema
The GraphQL API uses a schema to describe which data types are available in your system and how you can query them. From this article, you’ll learn how the Prepr GraphQL API schema is generated and how you can use it to integrate content into your web app.
Schema generation
A schema is the definition of the content structure for your web app. In Prepr, a schema consists of several content types: models, components, and remote sources. Each of these content types comes with corresponding fields.
Before adding content to Prepr, we recommend you design a schema with your content structure in a design tool of your choice.
Prepr provides you with the GraphQL API you can use to integrate the content into your application. For each content type in Prepr, the GraphQL API creates a corresponding GraphQL type (opens in a new tab), including available fields. These types describe the set of possible data you can query from Prepr.
Each of the GraphQL types and GraphQL fields must have a unique name as follows:
- The Type name is in pascal-case with only alphanumeric characters.
- The Field name is in lower camel-case with alphanumeric characters and underscores only.
Some Type names are reserved for metadata or default types. You can check them out in Reserved terms.
The GraphQL API schema is generated automatically at request time, so it’s always current. We recommend browsing a schema with an API Explorer (opens in a new tab) to get a complete overview of GraphQL type definitions and filtering options applicable to your setup. Also, you can inspect your schema using GraphQL Introspection (opens in a new tab).
Find more information about supported GraphQL types and fields by following the links below:
Querying a schema
Prepr provides an interface based on the Apollo Explorer to test your requests before integrating them into production. Within the API Explorer, you can write and validate your GraphQL queries, make a test run of the queries, and receive responses from the Prepr API straightaway. Find more information in Draft your queries.
Once you run a query, it will be validated and executed against the GraphQL API schema. The GraphQL API uses standard HTTP status codes to indicate whether a request is successful. Check out Statuses and errors for more details.
Reserved terms
The following Type names are default types and reserved for metadata:
Query, String, Int, Float, Boolean, Location, DateTime, Asset, Assets, Publication, Publications, ContentItem, ContentItems, Text, ApplePodcast, TwitterPost, InstagramPost, YouTubePost, FacebookPost, VimeoPost, SoundCloudPost, SpotifyPlaylist, TikTokPost, Coordinates, Quote, NavigationItem, Resource, BusinessHours, Tag, Customer, User, Channel, Story.
Including all types starting with _
and ending with _DESC
or _ASC
.
Using one of the reserved terms as a field name will result in a schema collision error asking you to use a different name instead.
Was this article helpful?
We’d love to learn from your feedback