{"record":{"id":"44c8128252a61447","repo":"OrchardCMS/OrchardCore","slug":"the-query-query-string-parameter-is-missing","errorCode":null,"errorMessage":"The 'query' query string parameter is missing","messagePattern":"The 'query' query string parameter is missing","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs","lineNumber":191,"sourceCode":"\n        context.Response.StatusCode = (int)(result.Errors == null || result.Errors.Count == 0\n            ? HttpStatusCode.OK\n            : result.Errors.Any(x => x is ValidationError ve && ve.Number == RequiresPermissionValidationRule.ErrorCode)\n                ? HttpStatusCode.Unauthorized\n                : HttpStatusCode.BadRequest);\n\n        context.Response.ContentType = MediaTypeNames.Application.Json;\n\n        await _serializer.WriteAsync(context.Response.Body, result);\n    }\n\n    private GraphQLNamedQueryRequest CreateRequestFromQueryString(HttpContext context, bool validateQueryKey = false)\n    {\n        if (!context.Request.Query.ContainsKey(\"query\"))\n        {\n            if (validateQueryKey)\n            {\n                throw new InvalidOperationException(\"The 'query' query string parameter is missing\");\n            }\n\n            return null;\n        }\n\n        var request = new GraphQLNamedQueryRequest\n        {\n            Query = context.Request.Query[\"query\"],\n        };\n\n        if (context.Request.Query.ContainsKey(\"variables\"))\n        {\n            request.Variables = _graphQLTextSerializer.Deserialize<Inputs>(context.Request.Query[\"variables\"]);\n        }\n\n        if (context.Request.Query.ContainsKey(\"operationName\"))\n        {\n            request.OperationName = context.Request.Query[\"operationName\"];","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs#L173-L209","documentation":"For GET requests (and non-JSON POSTs) GraphQLMiddleware reads the GraphQL query from the 'query' query string parameter. When it is absent and validation is enabled, CreateRequestFromQueryString throws this InvalidOperationException, surfaced to the client as a GraphQL processing error.","triggerScenarios":"GET /OrchardCore.Apis.GraphQL endpoint without ?query=..., or a POST with an unsupported content type and no ?query= query string parameter.","commonSituations":"Calling the endpoint with only variables or operationName in the URL, bookmarked/partially constructed URLs, clients omitting the query while intending a named query that doesn't exist.","solutions":["Append the query parameter: GET /api/graphql?query={ me { id } } (URL-encoded).","Double-check the parameter is exactly 'query' (lowercase) and correctly URL-encoded.","For persistent queries, register an INamedQueryProvider and pass ?query= via the named entry, or move to a POST JSON body.","Switch to POST with a JSON body when the query is large (avoids URL length limits)."],"exampleFix":"// before\nfetch('/api/graphql?variables={}')\n// after\nfetch('/api/graphql?query=' + encodeURIComponent('{ me { id } }'))","handlingStrategy":"validation","validationCode":"const url = '/api/graphql?query=' + encodeURIComponent(query);\nif (!query || !query.trim()) throw new Error('GraphQL query is required');","typeGuard":null,"tryCatchPattern":"const res = await fetch(url);\nconst result = await res.json();\nif (result.errors?.some(e => e.message.includes(\"'query' query string parameter is missing\"))) {\n    // reconstruct URL with the encoded query parameter\n}","preventionTips":["Always URL-encode the query when using GET.","Include ?query= even when also passing variables/operationName.","Prefer POST with a JSON body for long queries to avoid URL-length and encoding pitfalls."],"tags":["graphql","query-string","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}