Skip to content

Define Data Collections used in the spec #1102

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

benjie
Copy link
Member

@benjie benjie commented Jul 1, 2024

(Replacement of #1091; to do PR stack with #1092 and #1063)

The spec uses the terms "set", "list" and "map" in many places. This PR defines these terms and their conformance requirements.

This is a change extracted from #1063 as discussed at last night's WG meeting

The next PR in this stack is:

cc @graphql/tsc

Copy link

netlify bot commented Jul 1, 2024

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit f04f86f
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/682efc506e49100008983c96
😎 Deploy Preview https://deploy-preview-1102--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@andimarek andimarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one logical consistent way to describe these data structures is with a minimal amount of predefined terms would be:

  1. Everything is a collection. A collection is a finite group of elements that can be iterated over. The encounter order during iteration is not necessarily stable.

  2. A List is a specific collection where each element can be accessed via a stable Integer >= 0, called index and the encounter order is stable. A List allows for duplicate elements.

  3. A set is a specific collection where the elements are guaranteed to be unique. The encounter is not necessary stable ("unordered set"), but can be ("ordered set")
    (If we need to define unordered set vs ordered)

  4. A Map is a specific collection of elements, where each element is a pair (called "entry") made of a key and a value. All keys are a set, while all values is just a collection.
    The encounter order of a Map can be stable ("ordered Map") or not ("unordered Map")
    (If we need to define unordered Map vs ordered)

@benjie
Copy link
Member Author

benjie commented Apr 1, 2025

Hopefully my latest edit factors in @andimarek and @martinbonnin's feedback.


## Data Collections

A data collection is a finite, iterable aggregation of elements whose iteration
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'aggregation'?

  • collection: tautology - "a data collection is a collection"
  • set: we define "set" below, so using set here would introduce ambiguity
  • group: evokes group theory, best avoided
  • assembly: technically correct, but feels unnatural

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 Draft (RFC 2) RFC Stage 2 (See CONTRIBUTING.md)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants