diff --git a/app/graph/types/project_media_type.rb b/app/graph/types/project_media_type.rb index 5a67104fc3..aaed722128 100644 --- a/app/graph/types/project_media_type.rb +++ b/app/graph/types/project_media_type.rb @@ -172,6 +172,12 @@ def log(event_types: nil, field_names: nil, annotation_types: nil, who_dunnit: n object.get_versions_log(event_types, field_names, annotation_types, who_dunnit, include_related) end + field :flags, FlagType.connection_type, null: true + + def flags + object.get_annotations('flag').map(&:load) + end + field :tags, TagType.connection_type, null: true def tags diff --git a/app/models/annotations/flag.rb b/app/models/annotations/flag.rb deleted file mode 100644 index be790a768c..0000000000 --- a/app/models/annotations/flag.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Flag < ApplicationRecord - include AnnotationBase -end diff --git a/lib/relay.idl b/lib/relay.idl index 29b3ca7eb9..1112349207 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -8532,6 +8532,42 @@ type Flag implements Node { version: Version } +""" +The connection type for Flag. +""" +type FlagConnection { + """ + A list of edges. + """ + edges: [FlagEdge] + + """ + A list of nodes. + """ + nodes: [Flag] + + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + totalCount: Int +} + +""" +An edge in a connection. +""" +type FlagEdge { + """ + A cursor for use in pagination. + """ + cursor: String! + + """ + The item at the end of the edge. + """ + node: Flag +} + """ Autogenerated input type of GenerateTwoFactorBackupCodes """ @@ -11100,6 +11136,27 @@ type ProjectMedia implements Node { ): DynamicConnection feed_columns_values: JsonStringType field_value(annotation_type_field_name: String!): String + flags( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: String + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: String + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the last _n_ elements from the list. + """ + last: Int + ): FlagConnection full_url: String id: ID! is_confirmed: Boolean diff --git a/public/relay.json b/public/relay.json index d24f262c4b..08a1dd63dd 100644 --- a/public/relay.json +++ b/public/relay.json @@ -46592,6 +46592,132 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "FlagConnection", + "description": "The connection type for Flag.", + "fields": [ + { + "name": "edges", + "description": "A list of edges.", + "args": [ + + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "FlagEdge", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nodes", + "description": "A list of nodes.", + "args": [ + + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Flag", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "pageInfo", + "description": "Information to aid in pagination.", + "args": [ + + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "PageInfo", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "totalCount", + "description": null, + "args": [ + + ], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [ + + ], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "FlagEdge", + "description": "An edge in a connection.", + "fields": [ + { + "name": "cursor", + "description": "A cursor for use in pagination.", + "args": [ + + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "node", + "description": "The item at the end of the edge.", + "args": [ + + ], + "type": { + "kind": "OBJECT", + "name": "Flag", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [ + + ], + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "GenerateTwoFactorBackupCodesInput", @@ -58297,6 +58423,67 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "flags", + "description": null, + "args": [ + { + "name": "after", + "description": "Returns the elements in the list that come after the specified cursor.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "before", + "description": "Returns the elements in the list that come before the specified cursor.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "first", + "description": "Returns the first _n_ elements from the list.", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "last", + "description": "Returns the last _n_ elements from the list.", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "FlagConnection", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "full_url", "description": null, diff --git a/test/controllers/graphql_controller_test.rb b/test/controllers/graphql_controller_test.rb index 771f8cd3ee..564f898681 100644 --- a/test/controllers/graphql_controller_test.rb +++ b/test/controllers/graphql_controller_test.rb @@ -132,7 +132,7 @@ def setup authenticate_with_user(u) pm = create_project_media create_flag annotated: pm - query = "query GetById { project_media(ids: \"#{pm.id},nil,#{pm.team_id}\") { source { id }, annotation(annotation_type: \"flag\") { project_media { id } }, annotations(annotation_type: \"flag\") { edges { node { ... on Flag { id } } } } } }" + query = "query GetById { project_media(ids: \"#{pm.id},nil,#{pm.team_id}\") { source { id }, flags(first: 10) { edges { node { id } } }, annotation(annotation_type: \"flag\") { project_media { id } }, annotations(annotation_type: \"flag\") { edges { node { ... on Flag { id } } } } } }" post :create, params: { query: query, team: pm.team.slug } assert_response :success end