Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write query that pulls fruit/vegetable info from Trefle API #7

Open
capndave opened this issue Sep 24, 2020 · 13 comments
Open

Write query that pulls fruit/vegetable info from Trefle API #7

capndave opened this issue Sep 24, 2020 · 13 comments
Labels
enhancement New feature or request Hacktoberfest Work on this for Hacktoberfest! help wanted Extra attention is needed

Comments

@capndave
Copy link
Collaborator

capndave commented Sep 24, 2020

In Plants app, write handler to pull data from Trefle API. Ultimately we want a user of this (gardenbuilder-backend) to write a GraphQL query, passing in a fruit or vegetable name ("Tomato", for example). This handler/function would then query all of the tomato varieties from the Treffle API, return them, and then return all the tomato varieties to the user/graphql interface.

@capndave capndave added enhancement New feature or request help wanted Extra attention is needed Hacktoberfest Work on this for Hacktoberfest! labels Sep 24, 2020
@capndave capndave changed the title Write query that pulls fruit/vegetable info from treffle API Write query that pulls fruit/vegetable info from Trefle API Sep 24, 2020
@rexdivakar
Copy link

Assign it to me @capndave

@capndave
Copy link
Collaborator Author

Will do! If you would, please just set up your own account for the Trefle API, and import the connection settings into Django with an environment variable from a .env file in the config directory. I can swap out my Trefle credentials later. Please let me know if you have any difficulties getting this up and running!

@capndave
Copy link
Collaborator Author

capndave commented Oct 4, 2020

@rexdivakar let me know if you're still working on this, if not I'll unassign you

@rexdivakar
Copy link

Yes I'm working on it will update it soon @capndave

@rexdivakar
Copy link

hey @capndave Currently I'mpulling all the varieties of tomatoes, now i would like to know few details,

  1. What details should i pull out ?
  2. How do u want me to return the data (json or basic text) ?

image

@capndave
Copy link
Collaborator Author

capndave commented Oct 5, 2020

Awesome! The parameters I'd like to return to the client are { id, common_name, slug, scientific_name, image_url } for all tomato varieties. Let me know if there are pagination issues, like if you're unable to get all varieties with one api call.

@rexdivakar
Copy link

no prob, i can get it done but do u want the output in the form of list or dictionary ?

@capndave
Copy link
Collaborator Author

capndave commented Oct 5, 2020

Dictionary please. Basically you'll need to make a graphql query that accepts plantName (in the query itself) / plant_name (in python) and returns a bunch of items of class variety that include the parameters that you mention. The Trefle API call is just the intermediate step to actually fetch the data.

@rexdivakar
Copy link

I will raise the PR soon

@rexdivakar
Copy link

What do u think about dumping the data into a json file !! So we can even use it often with less network load ?

@capndave
Copy link
Collaborator Author

capndave commented Oct 6, 2020

GREAT idea! I guess we could just check the .json on each request from the client, and call Trefle if a top-level variety key isn't in the .json? I wonder if Redis or Memcache or something would be useful here, or overkill.

@rexdivakar
Copy link

If u have a larger work load we can go with Redis or Memcache but with smaller use case we can use .json (feed files) what do u say ?

@capndave
Copy link
Collaborator Author

capndave commented Oct 7, 2020 via email

@rexdivakar rexdivakar removed their assignment Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Hacktoberfest Work on this for Hacktoberfest! help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants