'How to allow anonymous introspection requests to Queries and Mutations behind Authorize attribute in Hot Chocolate 12?
Currently I have both my Query class and my Mutation class annotated with a HotChocolate.AspNetCore.Authorization.AuthorizeAttribute and that makes it mandatory to be authorized to get the schema. How do I allow anonymous access to the schema of queries and mutations that require authorization to work?
Solution 1:[1]
As far as I know it's not possible at this time, but there are supposed to come some changes in 13.0.0 to authorization, so it might be possible then. But can't confirm. I've tried quite a few things personally, and asked in the slack, and couldn't find a way to do it in the current version (12.2.8).
Solution 2:[2]
Convert string to int with the int() function:
mylist = [int(item) for item in mylist]
Now the list contains integers and not strings.
To be sure that no error occurs during conversion, use try-except:
for x in range(0, len(mylist)):
try:
mylist[x] = int(mylist[x])
except:
print("Error while converting item %s" % x)
The better solution that fits for your case is this one:
with open('servers.txt') as x:
try:
b = [int(line.strip()) for line in x]
except:
print("Error while converting line", line)
Hope those solutions help you.
Solution 3:[3]
Or You could forego the whole problem and use the builtin csv reader to read the file as tsv, or well I guess ssv in this case
import csv
with open( "servers.txt" ) as f:
csv.reader( f, delimiter=" " )
Solution 4:[4]
Look into this article : https://www.geeksforgeeks.org/python-converting-all-strings-in-list-to-integers/
for i in range(0, len(b)):
b[i] = int(test_list[b])
OR
b = [int(i) for i in b]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | oysandvik |
| Solution 2 | |
| Solution 3 | Arjun Ghosh |
| Solution 4 | Paul Kocian |
