You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if I'm misunderstanding what ariadne-codegen does. My understanding is that by giving Codegen access to the remote API, that it is crawling the schema and creating class types from the return types that it is observing. I also believe that it's supposed to do things like identify common object types and build data classes for them, then use those data classes whenever a query would indicate an instance of that class. For example, if Codegen notices that anywhere in the schema there is a 'tag' object, then it should be understanding that tags are a data class, and I should get Tag() objects back whenever one of my graphql queries would return a json structure containing tags, for example:
I should expect to get an Object parentObject with an attribute called tags which is a list of tag Objects.
However I'm not noticing that. Instead what I'm getting in response to my query is a HUGE object that seems to build child objects based off of the full name of the JSON path that they live on in the response. That, to me seems unusable. Observe:
importosfrompprintimportpprintimportjsonimportasynciofromgraphql_client.clientimportClientnerdgraph_url='https://api.newrelic.com/graphql'newrelic_api_key=os.environ.get('NEW_RELIC_API_KEY')
nerdgraph_client=Client(nerdgraph_url, {"Api-Key": newrelic_api_key})
asyncdefmain():
# have to use async withasyncwithnerdgraph_clientasclient:
result=awaitclient.aes(query="accountId = NR_ACCOUNT_ID AND name = 'NR_ENTITY_NAMME'")
pprint(result) # This doesn't work. I have to format with black after the factif__name__=="__main__":
asyncio.run(main())
Am I thinking about this incorrectly? This feels more cumbersome to interact with than just working with it as consumed JSON. What am I getting wrong about my approach?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm wondering if I'm misunderstanding what ariadne-codegen does. My understanding is that by giving Codegen access to the remote API, that it is crawling the schema and creating class types from the return types that it is observing. I also believe that it's supposed to do things like identify common object types and build data classes for them, then use those data classes whenever a query would indicate an instance of that class. For example, if Codegen notices that anywhere in the schema there is a 'tag' object, then it should be understanding that tags are a data class, and I should get Tag() objects back whenever one of my graphql queries would return a json structure containing tags, for example:
Given:
I should expect to get an Object
parentObject
with an attribute calledtags
which is a list oftag
Objects.However I'm not noticing that. Instead what I'm getting in response to my query is a HUGE object that seems to build child objects based off of the full name of the JSON path that they live on in the response. That, to me seems unusable. Observe:
Given:
queries/aes.gql
scratch.py
Output (values obfuscated)
Compare to the JSON response of the same query:
Am I thinking about this incorrectly? This feels more cumbersome to interact with than just working with it as consumed JSON. What am I getting wrong about my approach?
Beta Was this translation helpful? Give feedback.
All reactions