marmelab/react-admin · error · Error
Unknown resource ${resourceName}. Make sure it has been decl
Error message
Unknown resource ${resourceName}. Make sure it has been declared on your server side schema. Known resources are ${knownResources.join(', ')} What it means
buildQuery looks up the requested resource in the introspected GraphQL schema results. If no introspected type matches resourceName, the data provider cannot build any query and throws, listing the resources it does know.
Source
Thrown at packages/ra-data-graphql-simple/src/buildQuery.ts:23
export const buildQueryFactory =
(
buildVariablesImpl = buildVariables,
buildGqlQueryImpl = buildGqlQuery,
getResponseParserImpl = getResponseParser
) =>
(introspectionResults: IntrospectionResult): BuildQuery => {
const knownResources = introspectionResults.resources.map(
r => r.type.name
);
const buildQuery: BuildQuery = (raFetchType, resourceName, params) => {
const resource = introspectionResults.resources.find(
r => r.type.name === resourceName
);
if (!resource) {
throw new Error(
`Unknown resource ${resourceName}. Make sure it has been declared on your server side schema. Known resources are ${knownResources.join(
', '
)}`
);
}
const queryType = resource[raFetchType];
if (!queryType) {
throw new Error(
`No query or mutation matching fetch type ${raFetchType} could be found for resource ${resource.type.name}`
);
}
const variables = buildVariablesImpl(introspectionResults)(
resource,
raFetchType,
params,View on GitHub (pinned to 051f511bb0)
Solutions
- Match the resource name to the GraphQL type name exactly (check the known resources list in the error).
- Re-run/extend the introspection so the type is included (check the INTROSPECTION_QUERY / include/exclude options).
- Remove or rename the frontend <Resource> that has no server-side counterpart.
- Ensure the backend schema was deployed and exposes the type.
Example fix
// before <Resource name="posts" ... /> // GraphQL type is 'Post' // after <Resource name="Post" ... />
Defensive patterns
Strategy: validation
Validate before calling
const known = introspectionResults.resources.map(r => r.type.name);
if (!known.includes(resourceName)) {
console.warn(`Resource ${resourceName} missing from GraphQL schema; known: ${known.join(', ')}`);
} Type guard
const isKnownResource = (
name: string,
resources: { type: { name: string } }[]
): resources is { type: { name: string } }[] & { type: { name: string } }[] =>
resources.some(r => r.type.name === name); Try / catch
try {
return await dataProvider.getList(resourceName, params);
} catch (e) {
if (e.message.startsWith('Unknown resource')) {
console.error('Resource not in schema:', resourceName, e);
}
throw e;
} Prevention
- Name <Resource> entries exactly after GraphQL type names.
- Log the known-resources list at app bootstrap during development.
- Diff the introspected schema in CI to catch removed/renamed types.
When it happens
Trigger: Calling the data provider with a <Resource name="..."> or getList/getOne/etc. whose name does not match any type in introspectionResults.resources — e.g. fetching 'posts' when the GraphQL type is 'Post', or a resource absent from the queried schema.
Common situations: Case mismatch between Resource name and GraphQL type; resource added on the frontend before the backend schema exposes it; restrictive introspection query filtering out types; typo in resource name.
Related errors
- Requested sparse fields not found. Ensure sparse fields are
- No query or mutation matching fetch type ${raFetchType} coul
- Empty sparse fields. Specify at least one field or remove th
- ${(error?.networkError as ServerError)?.message}
- Unable to determine the query operation
AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30).
Data as JSON: /api/errors/53c54daed277f50e.
Report an issue: GitHub.