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

[RFC] Add note recommending directive names to be namespaced #657

Merged
merged 4 commits into from
Jan 10, 2020

Conversation

tinnou
Copy link
Contributor

@tinnou tinnou commented Dec 6, 2019

As discussed in the 2012-12-05 working group meeting, this informal RFC proposes adding a non-normative note recommending directive names to be namespaced to prevent name collisions when the specification adds new directives.

Motivation / Context

The Custom Scalar Specification URIs RFC was discussed during multiple working group meetings and the potential winning approach involves defining a new standard directive named @specified. Existing GraphQL schemas that already defined this directive would now break as directive names must be unique. To prevent this inconvenience, it was proposed we add an explicit note to the specification recommending schema designers to prefix/namespace directive names to prevent name collisions when upgrading their GraphQL server.

Open Questions

  • I couldn't find any nomenclature in the specification to differentiate directives defined by the specification and directives defined by schema designers. I did "hear" terms such as "standard", "built-in" for the former, and "custom" directives for the latter. Maybe it would be a good idea to introduce such terms to make the specification text clearer. Thoughts?
  • I added an example but I can remove it if it is deemed unnecessary.

@tinnou
Copy link
Contributor Author

tinnou commented Dec 6, 2019

Implements #646

Note: When defining a directive, it is recommended to namespace the directive name
to prevent name collisions with directives added in future versions of the specification.
For example, `@fb_auth` directive would represent an authentication directive
with the prefix `fb` as namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thus, we are talking about the prefix, and not about the namespace. GraphQL has no concept of namespaces. Perhaps the term namespace is not worth mentioning at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What other term would you use then?

I didn’t want to only use the term  « prefix » because it focuses on the how rather than what we are trying to achieve. One can use any other technique like suffixing if they prefer, to achieve « namespacing ».

Copy link
Contributor

Choose a reason for hiding this comment

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

I say that the term namespace should not be used, because as a rule a certain meaning is invested in it. In addition, some syntax rules are always associated with namespaces. There is nothing here. Despite the fact that someone may not like the term prefix (I don't like it either), it is described here - without clear syntax rules.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, especially since there's been past discussion about adding namespaces as a first class concept to GraphQL. We didn't follow that path, but we both want to avoid confusion and make sure that in some rare case we revisit namespaces that we don't accidentally create an ambiguity here.

@eapache
Copy link
Member

eapache commented Dec 6, 2019

👍 from me on the intent, just some details to iron out.

I couldn't find any nomenclature in the specification to differentiate directives defined by the specification and directives defined by schema designers. I did "hear" terms such as "standard", "built-in" for the former, and "custom" directives for the latter. Maybe it would be a good idea to introduce such terms to make the specification text clearer. Thoughts?

I could be wrong, but I think the term "custom" and is well-understood in this context already?

@leebyron leebyron added the ✏️ Editorial PR is non-normative or does not influence implementation label Jan 10, 2020
Copy link
Collaborator

@leebyron leebyron left a comment

Choose a reason for hiding this comment

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

Huge thanks for getting this started and my apologies for the late review.

I'll make some editorial edits and get this merged.

Note: When defining a directive, it is recommended to namespace the directive name
to prevent name collisions with directives added in future versions of the specification.
For example, `@fb_auth` directive would represent an authentication directive
with the prefix `fb` as namespace.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, especially since there's been past discussion about adding namespaces as a first class concept to GraphQL. We didn't follow that path, but we both want to avoid confusion and make sure that in some rare case we revisit namespaces that we don't accidentally create an ambiguity here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Editorial PR is non-normative or does not influence implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants