Skip to content

Collections: do not expose custom functions #15269

Backlog

Description

@shykes

Problem

A collection exposes the custom functions of the module next to the engine operations (keys, list, get, subset). They share one namespace:

  • A custom function with the name of an engine operation causes a conflict.
  • Each new engine operation can break existing modules.

See #15137.

Solution

Do not expose custom functions on a collection. A collection exposes only the engine operations. Put custom functions on the collection item.

Example module:

type GoPackages @collection {
  # Part of the collection interface
  keys: [String!]!
  get(name: String!): GoPackage!

  # Not part of the collection interface
  runTests: Boolean! { ... }
  tidy: GoPackages! { ... }
}

Now the engine exposes this:

type GoPackages {
  id: GoPackagesID!
  keys: [String!]!
  list: [GoPackage!]!
  get(key: String!): GoPackage!
  subset(keys: [String!]!): GoPackages!

  # Custom functions
  runTests: Boolean!
  tidy: GoPackages!
}

After this change, the engine exposes this:

type GoPackages {
  id: GoPackagesID!
  keys: [String!]!
  list: [GoPackage!]!
  get(key: String!): GoPackage!
  subset(keys: [String!]!): GoPackages!
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions