|
| 1 | +# Fully Qualified Operation Name (FQON) |
| 2 | + |
| 3 | +**Introduction** |
| 4 | + |
| 5 | +:: This document specifies _Fully Qualified Operation Name_ (FQON), a |
| 6 | +human‑readable, unambiguous identifier for GraphQL operations. |
| 7 | + |
| 8 | +The primary motivation is to define a "lookup key" that may be used in static |
| 9 | +configuration files (e.g. for alerting rules per operation) which correctly |
| 10 | +targets operations, but without having to update the configuration each time a |
| 11 | +_document id_ changes. |
| 12 | + |
| 13 | +This specification assumes usage of |
| 14 | +[trusted documents](https://graphql.org/learn/security/#trusted-documents) and |
| 15 | +[Git version control](https://git-scm.com/). |
| 16 | + |
| 17 | +**Example** |
| 18 | + |
| 19 | +Given the following operation defined in a Git repository named `yelp/frontend`, |
| 20 | +and in a package named `styleguide`: |
| 21 | + |
| 22 | +```graphql example |
| 23 | +query GetHeaderData { |
| 24 | + ... |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +The _FQON_ for this operation may be defined as: |
| 29 | + |
| 30 | +```example |
| 31 | +GetHeaderData:styleguide:yelp/frontend:1 |
| 32 | +``` |
| 33 | + |
| 34 | +When defining alerting rules for this operation, we can target all versions of |
| 35 | +this operation by omitting the _version_ suffix: |
| 36 | + |
| 37 | +```example |
| 38 | +GetHeaderData:styleguide:yelp/frontend |
| 39 | +``` |
| 40 | + |
| 41 | +**Motivation** |
| 42 | + |
| 43 | +We may identify operations using either: |
| 44 | + |
| 45 | +- The _operation name_ (e.g. {"GetHeaderData"}) |
| 46 | +- The _document id_ produced by hashing the operation body (e.g. {"605fad0ee0a88..."}) |
| 47 | + |
| 48 | +Because GraphQL operation names are not be guaranteed to be globally unique, |
| 49 | +they cannot reliably identify an operation across multiple platforms or |
| 50 | +deployment versions. On the other hand, a _document id_ is guaranteed to be |
| 51 | +unique but is inconvenient for humans to read and maintain. |
| 52 | + |
| 53 | +Note: See <README.md> for additional context. |
| 54 | + |
| 55 | +**Use Cases** |
| 56 | + |
| 57 | +- A _FQON_ may be printed instead of the operation name in application logs. |
| 58 | + This encourages correct behavior when humans use this identifier to look up |
| 59 | + the operation body in the document registry or codebase. |
| 60 | +- A partial _FQON_ may be used instead of a _document id_ as lookup keys in |
| 61 | + static configuration files (e.g. alerting rules) in order to avoid duplication |
| 62 | + and extra steps when an operation is updated (and thus, its _document id_). |
| 63 | + |
| 64 | +## Definition |
| 65 | + |
| 66 | +FullyQualifiedOperationName :: OperationName : Project? : RepoFullName : Version |
| 67 | + |
| 68 | +OperationName |
| 69 | +: The _Name_ of the operation as declared on the _OperationDefinition_ node. |
| 70 | + |
| 71 | +Project |
| 72 | +: The identifier for the package or directory containing the operation. |
| 73 | +: This is defined only for operations that live in a monorepo. |
| 74 | + |
| 75 | +RepoFullName |
| 76 | +: The full name of the Git repository (in the format of {"owner/repo"}). |
| 77 | + |
| 78 | +Version |
| 79 | +: A positive integer that increments each time the document body changes. |
| 80 | +: The tuple of _OperationName_, _Project_ and _RepoFullName_ identifies a |
| 81 | +document; the _Version_ part distinguishes its revisions. |
| 82 | +: The _trusted document_ registry or other persistence layer must calculate or |
| 83 | +store version numbers, starting at {1} and increasing monotonically. |
| 84 | + |
| 85 | +**Examples** |
| 86 | + |
| 87 | +A _Fully Qualified Operation Name_ with all parts: |
| 88 | + |
| 89 | +```example |
| 90 | +GetHeaderData:styleguide:yelp/frontend:1 |
| 91 | +``` |
| 92 | + |
| 93 | +A _Fully Qualified Operation Name_ which omits `Project` (i.e. |
| 94 | +`petstore/website` is _not_ a monorepo, and has no concept of "projects"): |
| 95 | + |
| 96 | +```example |
| 97 | +AllPets::petstore/website:1 |
| 98 | +``` |
| 99 | + |
| 100 | +## Partial Matches |
| 101 | + |
| 102 | +Any _FQON_ part may be omitted to perform a partial match. |
| 103 | + |
| 104 | +With the exception of omitting _Project_, partial matches must also omit the |
| 105 | +`:Version` suffix. |
| 106 | + |
| 107 | +The primary use case of this specification is to omit `:Version` for use as |
| 108 | +lookup keys in static configuration files, as a way to target to all versions |
| 109 | +of an operation. |
| 110 | + |
| 111 | +**Examples** |
| 112 | + |
| 113 | +| Pattern | Matches | |
| 114 | +| --------------------------- | ------------------------------------------------------------------------------------------------------- | |
| 115 | +| `GetFoo::` | All operations named {"GetFoo"} | |
| 116 | +| `::bazcorp/qux` | All operations inside the {"bazcorp/qux"} Git repository | |
| 117 | +| `GetFoo:barpkg:bazcorp/qux` | All operations named {"GetFoo"} inside the {"barpkg"} package inside the {"bazcorp/qux"} Git repository | |
| 118 | + |
| 119 | +## Security Considerations |
| 120 | + |
| 121 | +It is recommended to avoid exposing FQONs in client code to avoid leaking |
| 122 | +potentially sensitive internal repository names or project/directory names. |
| 123 | + |
| 124 | +Clients should still send only the _document id_ over the wire, which is opaque. |
0 commit comments