Graphql logo

Graphql

Organization
api-platform
graphql

Exposes API Platform resources over GraphQL — enabling GraphQL, Query/QueryCollection/Mutation/DeleteMutation operations, security expressions, custom resolvers, Relay cursor pagination, and nested relations. Use when the user mentions GraphQL, a GraphQL schema, queries/mutations, Relay connections, GraphQL playground, resolvers, or asks to expose existing REST resources via GraphQL.

Overview

Publisherapi-platform
Repositoryskillset
Skill namegraphql
Stars
29
Forks
1
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by api-platform on GitHub. Read the source before you install it.

Installation

Install the Graphql AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/api-platform/skillset/tree/main/skills/graphql
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/api-platform/skillset.git /tmp/skillset
mkdir -p .claude/skills
cp -r /tmp/skillset/skills/graphql .claude/skills/graphql
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Graphql in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Graphql on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Graphql is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

GraphQL

Default to REST. GraphQL trades away things API Platform gives you for free over REST: HTTP cache semantics (ETag, Cache-Control, invalidation), one URL per resource, simple CDN/proxy caching, and predictable per-operation cost. A single GraphQL query can fan out into arbitrarily deep/expensive resolution. Reach for GraphQL when it is a hard client requirement (e.g. a Relay/Apollo frontend, or clients that genuinely need to select fields and avoid round-trips) — not as a default. The same resource class can serve both; you don't have to choose globally.

Enabling GraphQL

Install api-platform/graphql (composer require api-platform/graphql), then it's on. A /graphql endpoint and the GraphiQL playground (/graphql/graphiql) appear. Disable globally or per resource as needed:

yaml
# config/packages/api_platform.yaml
api_platform:
    graphql:
        enabled: true
        graphiql:
            enabled: true

Declaring GraphQL operations

GraphQL operations live in graphQlOperations and are separate classes from the REST ones, under ApiPlatform\Metadata\GraphQl\. A resource with no graphQlOperations still gets a default set (item query, collection query, create / update / delete mutations) once GraphQL is enabled.

php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GraphQl\DeleteMutation;
use ApiPlatform\Metadata\GraphQl\Mutation;
use ApiPlatform\Metadata\GraphQl\Query;
use ApiPlatform\Metadata\GraphQl\QueryCollection;

#[ApiResource(graphQlOperations: [
    new Query(),
    new QueryCollection(),
    new Mutation(name: 'create'),
    new Mutation(name: 'update'),
    new DeleteMutation(name: 'delete'),
])]
class Book {}

Mutation and DeleteMutation require a name — it becomes the GraphQL field name (createBook, updateBook, deleteBook). Query and QueryCollection only need a name when you declare more than one of the same kind (e.g. a custom query alongside the default).

Security on GraphQL operations

Same ExpressionLanguage as REST (see operations), set per GraphQl operation:

php
new Query(security: "is_granted('ROLE_USER')")
new Mutation(name: 'update', security: "object.getOwner() == user")
new Mutation(name: 'update', securityPostDenormalize: "object.getOwner() == user")

Because one GraphQL query can traverse relations, securing only the top-level operation is not enough — guard the related resources' operations too, or a nested field becomes an unguarded read path.

Custom resolvers

Use a resolver when a query/mutation needs logic beyond fetch-by-id. Resolvers are services implementing one of:

  • QueryItemResolverInterface — __invoke(?object $item, array $context): object
  • QueryCollectionResolverInterface — __invoke(iterable $collection, array $context): iterable
  • MutationResolverInterface — __invoke(?object $item, array $context): ?object

Query arguments arrive in $context['args'].

php
use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface;

final class BookResolver implements QueryItemResolverInterface
{
    public function __invoke(?object $item, array $context): object
    {
        // $item is the fetched Book (or null if read: false); enrich or replace it
        return $item;
    }
}

With Symfony autoconfiguration the resolver is wired automatically. Without it, tag the service api_platform.graphql.query_resolver (or ..._mutation_resolver). Then reference it by class name on the operation, and set read: false when the resolver should fetch the data itself rather than receiving a hydrated item:

php
new Query(name: 'recommended', resolver: BookResolver::class, read: false)
new Query(
    name: 'search',
    resolver: BookResolver::class,
    args: [
        'query' => ['type' => 'String!', 'description' => 'Full-text search'],
        'limit' => ['type' => 'Int'],
    ],
)

args overrides the auto-generated argument set — define it when the query takes parameters that aren't resource fields.

Relations and the N+1 trap

GraphQL embeds related resources by selecting nested fields:

graphql
{
  book(id: "/books/1") {
    title
    author { name }
  }
}

Relations resolve through the same providers as REST. A deeply nested query can trigger many small queries (the classic N+1). API Platform mitigates common cases, but verify against real queries and add Doctrine joins / a custom collection provider where a hot path fans out. This open-ended cost is the main reason REST is the safer default for cache-sensitive APIs.

Pagination: Relay cursor connections

Collection queries return Relay-style cursor connections by default (edges { node { ... } cursor }, pageInfo, totalCount), driven by first/ after/last/before arguments:

graphql
{
  books(first: 10, after: "endCursor") {
    totalCount
    edges { node { title } cursor }
    pageInfo { endCursor hasNextPage }
  }
}

To use simple page-based pagination instead, set paginationType: 'page' on the resource or the QueryCollection:

php
use ApiPlatform\Metadata\GraphQl\QueryCollection;

#[ApiResource(graphQlOperations: [
    new QueryCollection(paginationType: 'page'),
])]
class Book {}

All the pagination* controls from pagination (items per page, max, partial) apply to GraphQL collections too.

Real-time subscriptions

When a resource has mercure: true, GraphQL subscription operations push updates through the Mercure hub — see mercure.

Laravel

GraphQL is supported on Laravel. The operation classes (Query, QueryCollection, Mutation, DeleteMutation), security expressions, Relay connections, paginationType, custom resolvers and the N+1 caveats are all the same. Differences:

  • Install composer require api-platform/graphql, then enable it in config/api-platform.php under graphql ('enabled' => true) — not YAML. Depth/ complexity limits and graphiql live in the same config block.
  • Resolvers implement the same QueryItemResolverInterface / QueryCollectionResolverInterface / MutationResolverInterface and are referenced by class-string on the operation; Laravel's container resolves them — there are no api_platform.graphql.*_resolver tags to apply.
  • Real-time subscription operations depend on Mercure, which has no Laravel integration (see mercure), so GraphQL subscriptions are effectively Symfony-only.

Checklist

  • GraphQL chosen for a real client requirement, not as a REST default
  • Every Mutation/DeleteMutation has a name
  • security set on nested resources, not just the entry-point operation
  • Custom resolvers tagged (or autoconfigured) and referenced by class name
  • read: false set when the resolver fetches its own data
  • Deep/nested queries checked for N+1; joins added on hot paths
  • paginationType: 'page' set only if the client doesn't want Relay connections

Frequently asked questions

What does the Graphql AI skill do?

Exposes API Platform resources over GraphQL — enabling GraphQL, Query/QueryCollection/Mutation/DeleteMutation operations, security expressions, custom resolvers, Relay cursor pagination, and nested relations. Use when the user mentions GraphQL, a GraphQL schema, queries/mutations, Relay connections, GraphQL playground, resolvers, or asks to expose existing REST resources via GraphQL.

Why use Graphql on TypingMind?

Because you install it once and use it with any model. Graphql is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Graphql in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/api-platform/skillset/tree/main/skills/graphql. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Graphql?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Graphql?

As many as you like. As long as a model supports skills, you can use Graphql with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Graphql AI skill free?

It is published on GitHub by api-platform. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇