Skip to content

Commit

Permalink
Update argument of qrExists query for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
pylipp committed Sep 9, 2024
1 parent 4a5e8e5 commit 7ee08fb
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@


@query.field("qrExists")
def resolve_qr_exists(*_, qr_code):
def resolve_qr_exists(*_, code):
authorize(permission="qr:read")
try:
QrCode.get_id_from_code(qr_code)
QrCode.get_id_from_code(code)
except QrCode.DoesNotExist:
return False
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Query {
boxes(baseId: ID!, paginationInput: PaginationInput, filterInput: FilterBoxInput): BoxPage!
" Return [`QrCode`]({{Types.QrCode}}) with specified code (an MD5 hash in hex format of length 32), or an error in case of insufficient permission or missing resource. "
qrCode(code: String!): QrCodeResult!
qrExists(qrCode: String): Boolean
qrExists(code: String): Boolean
" Return [`ClassicLocation`]({{Types.ClassicLocation}}) with specified ID. Accessible for clients who are members of the location's base "
location(id: ID!): ClassicLocation
" Return all [`ClassicLocations`]({{Types.ClassicLocation}}) that the client is authorized to view. "
Expand Down
2 changes: 1 addition & 1 deletion back/test/endpoint_tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def operation_name(operation):
# Test case 8.1.3
"""box( labelIdentifier: "12345678") { id }""",
# Test case 8.1.35
"""qrExists( qrCode: "1337beef" )""",
"""qrExists( code: "1337beef" )""",
],
ids=operation_name,
)
Expand Down
4 changes: 2 additions & 2 deletions back/test/endpoint_tests/test_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def test_qr_exists_query(read_only_client, default_qr_code):
# Test case 8.1.33
code = default_qr_code["code"]
query = f"""query CheckQrExistence {{
qrExists(qrCode: "{code}")
qrExists(code: "{code}")
}}"""
qr_exists = assert_successful_request(read_only_client, query)
assert qr_exists

# Test case 8.1.34
query = """query CheckQrExistence {
qrExists(qrCode: "000")
qrExists(code: "000")
}"""
qr_exists = assert_successful_request(read_only_client, query)
assert not qr_exists
Expand Down
2 changes: 1 addition & 1 deletion front/src/queries/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE = gql`

export const CHECK_IF_QR_EXISTS_IN_DB = gql`
query CheckIfQrExistsInDb($qrCode: String!) {
qrExists(qrCode: $qrCode)
qrExists(code: $qrCode)
}
`;

Expand Down
2 changes: 1 addition & 1 deletion front/src/types/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ export type QueryQrCodeArgs = {


export type QueryQrExistsArgs = {
qrCode?: InputMaybe<Scalars['String']>;
code?: InputMaybe<Scalars['String']>;
};


Expand Down

0 comments on commit 7ee08fb

Please sign in to comment.