Skip to content

Make GraphQL schema overridable #7636

Open
@richardguerre

Description

@richardguerre

New Feature / Enhancement Checklist

Current Limitation

When trying to tighten the GraphQL type definitions by example changing a Parse number field to be Int instead of Float in the GraphQL schema.
Currently getting this error in the server logs, when trying to override a number field with type Int:

error: Error: Field "MyClass.numberField" already exists in the schema. It cannot also be defined in this type extension.
  at assertValidSDLExtension (/parse-server/node_modules/graphql/validation/validate.js:124:11)
  at Object.extendSchema (/parse-server/node_modules/graphql/utilities/extendSchema.js:77:43)
  at /parse-server/node_modules/@graphql-tools/stitch/index.cjs.js:1232:28
  at Array.forEach (<anonymous>)
  at stitchSchemas (/parse-server/node_modules/@graphql-tools/stitch/index.cjs.js:1231:16)
  at ParseGraphQLSchema.load (/parse-server/lib/GraphQL/ParseGraphQLSchema.js:212:56)
  at processTicksAndRejections (internal/process/task_queues.js:93:5)
  at async ParseGraphQLServer._getGraphQLOptions (/parse-server/lib/GraphQL/ParseGraphQLServer.js:61:17)
  at async /parse-server/lib/GraphQL/ParseGraphQLServer.js:99:86

Feature / Enhancement Description

Allow overriding of existing field types in the GraphQL schema.

Example Use Case

  1. Create a class, MyClass, with a field of type Number
  2. Extend graphql schema by adding
extend type MyClass {
  numberField: Int
}

# If I also know that all my numbers are all integers, then I can do this too:
extend input NumberWhereInput {
  equalTo: Int
  notEqualTo: Int
  lessThan: Int
  lessThanOrEqualTo: Int
  greaterThan: Int
  greaterThanOrEqualTo: Int
  in: [Int]
  notIn: [Int]
}

Alternatives / Workarounds

Currently working with Float instead of Int but would prefer to have a clear distinction between actual Floats and Ints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:docsOnly change in the docs or README

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions