Generate GraphQL reference
Fern generates API Reference documentation from a GraphQL schema. Add your schema file to your Fern project and Fern renders queries, mutations, subscriptions, and types as an interactive reference.
How to add a GraphQL endpoint
- Add your GraphQL schema files to your
/ferndirectory. - Configure your
generators.ymlto point to your GraphQL schemas:
- Reference the API in your
docs.ymlnavigation:
Configuration properties
Path to your GraphQL schema file. You can include multiple GraphQL specs if your project exposes more than one GraphQL API.
Name of the folder that operations from this spec appear under in the API Reference sidebar. Use this to group related GraphQL operations together.
URL of your GraphQL API endpoint. Fern performs introspection against this endpoint to fetch the schema. When set, running fern api update updates the local schema from this endpoint.
Include more than one GraphQL reference
To include multiple GraphQL definitions in your documentation, use the api-name property:
Organize each schema in a separate directory within your Fern project:
Customize the layout
Use the layout property in docs.yml to control how GraphQL operations appear in the sidebar. Reference individual operations with the operation keyword using the format OPERATION_TYPE operationName, where OPERATION_TYPE is QUERY, MUTATION, or SUBSCRIPTION.
You can also set a custom title, slug, hidden, or availability on each operation:
Group operations into sections
Organize operations under custom sections:
Namespaced operations
If your schema includes operations that share the same name across different namespaces, use dot notation to disambiguate:
For the full set of layout options that apply to all API types (alphabetizing, flattening, adding pages and links, and more), see Customize API Reference layout.