{"record":{"id":"5cc72c6654ad1dc0","repo":"dgraph-io/dgraph","slug":"expected-type-for-the-field-s-is-s-but-got-s-in","errorCode":null,"errorMessage":"expected type for the field %s is %s but got %s in type %s","messagePattern":"expected type for the field (.+?) is (.+?) but got (.+?) in type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/remote.go","lineNumber":393,"sourceCode":"\t\t\t\tif remoteFields == nil {\n\t\t\t\t\t// Get fields for INPUT_OBJECT\n\t\t\t\t\tremoteFields = remoteType.InputFields\n\t\t\t\t}\n\t\t\t\tfor _, field := range fields {\n\t\t\t\t\tvar remoteField *gqlField = nil\n\t\t\t\t\tfor _, rf := range remoteFields {\n\t\t\t\t\t\tif rf.Name == field.Name {\n\t\t\t\t\t\t\tremoteField = rf\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif remoteField == nil {\n\t\t\t\t\t\treturn errors.Errorf(\n\t\t\t\t\t\t\t\"%s field for the local type %s is not present in the remote type %s\",\n\t\t\t\t\t\t\tfield.Name, typeName, remoteType.Name,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif remoteField.Type.String() != field.Type.String() {\n\t\t\t\t\t\treturn errors.Errorf(\n\t\t\t\t\t\t\t\"expected type for the field %s is %s but got %s in type %s\",\n\t\t\t\t\t\t\tremoteField.Name,\n\t\t\t\t\t\t\tremoteField.Type.String(),\n\t\t\t\t\t\t\tfield.Type.String(),\n\t\t\t\t\t\t\ttypeName,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// matchArgSignature matches the type signature for arguments supplied in metadata with\n// corresponding remote arguments\nfunc matchArgSignature(md *argMatchingMetadata) error {\n\t// TODO: maybe add path information in error messages,","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/remote.go#L375-L411","documentation":"During remote GraphQL schema composition, each field of a local type is compared against the corresponding field of the remote type. When the remote field's resolved type string differs from the local field's type string, this error is thrown from matchRemoteTypes (invoked via matchDeepTypes). It guarantees the local schema stays type-compatible with the upstream remote schema before federation/joining.","triggerScenarios":"Calling schema composition / remote merge APIs (e.g. validateRemoteGraphql / AddRemoteSchema in graphql-go/relay-style remote.go) after the upstream service changed a field's type (e.g. Int -> String, [User] -> User, String -> String!), or the local override schema declares a different type for a field that also exists remotely.","commonSituations":"Upstream GraphQL service upgraded and changed a field's type or nullability; a hand-written local schema in a config file drifted from the remote SDL; copying a type definition into the local schema with a slightly different wrapper ([T] vs T vs T!).","solutions":["Diff the local type against the remote schema (graphiql introspection or `graphql-schema` diff) and update the local field definition to match remoteField.Type exactly, including NonNull and List wrappers.","If the local type is authoritative, update or pin the remote schema/version so the field type matches (e.g. pin the upstream service version in config).","Re-run schema composition after fixing and check the other errors it reports; usually one type change cascades into several field mismatches.","If intentional divergence is needed, rename the local field/type so the matcher does not pair them."],"exampleFix":"// before (local schema)\nuser: Int\n// remote schema: user: String!\n// after\nuser: String!","handlingStrategy":"validation","validationCode":"// Before composing, diff local vs remote types\nfunc validateFieldType(local, remote *graphql.Type) error {\n    if local.String() != remote.String() {\n        return fmt.Errorf(\"field type drift: local=%s remote=%s\", local, remote.String())\n    }\n    return nil\n}\n// Run over every shared type before calling AddRemoteSchema/validateRemoteGraphql","typeGuard":"func typesMatch(a, b string) bool { return a == b } // compare Type.String() output including wrappers","tryCatchPattern":"if err := validateRemoteGraphql(schema, remoteSchema, query); err != nil {\n    if strings.Contains(err.Error(), \"expected type for the field\") {\n        log.Fatalf(\"schema drift detected: %v\", err) // fix SDL, not retryable\n    }\n    return err\n}","preventionTips":["Pin and version remote SDL; re-introspect on upgrades","Run schema-diff in CI against upstream before deploying composition","Keep local type definitions generated from the remote SDL, never hand-edited","Include nullability/list wrappers when copying types"],"tags":["graphql","schema-mismatch","remote-schema"],"backgroundTag":"graphql-schema-type-mismatch","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}