Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty objects during development #482

Open
jasonkuhrt opened this issue Jul 10, 2020 · 0 comments
Open

Support empty objects during development #482

jasonkuhrt opened this issue Jul 10, 2020 · 0 comments
Labels
type/feat Add a new capability or enhance an existing one

Comments

@jasonkuhrt
Copy link
Contributor

Perceived Problem

  • @nexus/schema will tolerate empty objects
  • Empty objects are not valid in a GraphQL schema, at runtime
  • They used to be invalid at schema definition time too but that limit was lifted Allow defining empty types graphql/graphql-js#937
  • result is makeSchema leads to invalid schemas that won't be caught until runtime

Ideas / Proposed Solution(s)

  • @nexus/schema

    • should never produce schemas that will never run

    • fill the empty objects with a placeholder field, e.g.

      object Something {
        """This object is empty in your schema. Nexus has added this field for you. In production [...]"""
        todo: Boolean
      }
    • should expose a way for consumer to configure the field. Should pass some data for consumer to make useful log messages.

      makeSchema({
        on: {
          emptyObject: (object: GraphQLObjectType) => { type: 'remove' } | { type: 'placehold', fieldName?: string, fieldType?: string, heredoc?: string }
        }
      })
    • default: fail in prod, warn in dev

  • nexus

    • configure @nexus/schema to placehold during dev but remove and error during prod
    • customize log message to integrate into logger
@jasonkuhrt jasonkuhrt transferred this issue from prisma-labs/graphql-framework-experiment Aug 7, 2020
@jasonkuhrt jasonkuhrt added the type/feat Add a new capability or enhance an existing one label Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

No branches or pull requests

1 participant