{"record":{"id":"b87a60efaa8648ec","repo":"dgraph-io/dgraph","slug":"remote-schema-doesn-t-have-any-queries","errorCode":null,"errorMessage":"remote schema doesn't have any queries.","messagePattern":"remote schema doesn't have any queries\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/remote.go","lineNumber":238,"sourceCode":"\ttypMap map[string]*gqlType\n\t// requiredArgs is the list of NON_NULL args in remote query\n\trequiredArgs []string\n}\n\n// validates the graphql given in @custom->http->graphql by introspecting remote schema.\n// It assumes that the graphql syntax is correct, only remote validation is needed.\nfunc validateRemoteGraphql(metadata *remoteGraphqlMetadata) error {\n\tremoteIntrospection, err := introspectRemoteSchema(metadata.url, metadata.headers)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar remoteQueryTypename string\n\toperationType := string(metadata.graphqlOpDef.Operation)\n\tswitch operationType {\n\tcase \"query\":\n\t\tif remoteIntrospection.Data.Schema.QueryType == nil {\n\t\t\treturn errors.Errorf(\"remote schema doesn't have any queries.\")\n\t\t}\n\t\tremoteQueryTypename = remoteIntrospection.Data.Schema.QueryType.Name\n\tcase \"mutation\":\n\t\tif remoteIntrospection.Data.Schema.MutationType == nil {\n\t\t\treturn errors.Errorf(\"remote schema doesn't have any mutations.\")\n\t\t}\n\t\tremoteQueryTypename = remoteIntrospection.Data.Schema.MutationType.Name\n\tdefault:\n\t\t// this case is not possible as we are validating the operation to be query/mutation in\n\t\t// @custom directive validation\n\t\treturn errors.Errorf(\"found `%s` operation, it can only have query/mutation.\", operationType)\n\t}\n\n\tremoteTypes := make(map[string]*types)\n\tfor _, typ := range remoteIntrospection.Data.Schema.Types {\n\t\tremoteTypes[typ.Name] = typ\n\t}\n","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/remote.go#L220-L256","documentation":"During custom directive validation, Dgraph introspects the remote schema and reads its operation types. If the remote schema advertises no query type (Schema.QueryType is nil) while the local @custom usage needs a query, this error is raised. A GraphQL schema without queries is legal per spec but cannot serve the custom query fields Dgraph is validating.","triggerScenarios":"Adding a @custom directive pointing at a remote GraphQL endpoint whose schema only defines mutations (or the introspection result has queryType: null), then running schema update/validation via validateRemoteGraphql.","commonSituations":"Pointing @custom at a mutation-only remote service; misconfigured URL hitting the wrong endpoint; a remote server with disabled introspection returning a schema stub without queryType.","solutions":["Point the @custom directive at a remote schema that exposes queries","If you need a mutation, use @custom with mode MUTATION instead of QUERY","Verify the remote's introspection returns a proper queryType (test with a GraphQL playground)"],"exampleFix":"// before\nfield: \"addUser\"\n@custom(http: {url: \"https://remote/mutationOnly\", method: POST}, mode: QUERY)\n// after\nfield: \"addUser\"\n@custom(http: {url: \"https://remote/mutationOnly\", method: POST}, mode: MUTATION)","handlingStrategy":"validation","validationCode":"const intro = await fetch(url, introspectionPost)\nconst schema = (await intro.json()).data?.__schema\nif (!schema?.queryType) throw new Error('remote schema has no query type')","typeGuard":"func remoteHasQueries(i *introspectedSchema) bool {\n  return i != nil && i.Data != nil && i.Data.Schema != nil && i.Data.Schema.QueryType != nil\n}","tryCatchPattern":"err := schema.ValidateCustom(dgSchema, gqlSchema)\nif err != nil && strings.Contains(err.Error(), \"doesn't have any queries\") {\n  // switch the @custom directive to mode MUTATION or point to a query-capable remote\n}","preventionTips":["Inspect the remote schema in a playground before referencing it in @custom","Use mode MUTATION for mutation-only remotes","Verify introspection is enabled on the remote server"],"tags":["graphql","remote-schema","custom-directive","validation","dgraph"],"backgroundTag":"remote-schema-missing-queries","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}