unable to post data to a graphql api using streamlit

Viewed 59

I am building a user profile page using streamlit and when he submits it the data is stored in a the graphql api using mutations. Here i am using requests but the data is not mutating nor showing error.Need help

url = "https://graphql-newone.herokuapp.com/"

query = """mutation {
                createUsers(input:{
                user_name: "${name}"
                age: ${age}
                sex: "${sex}"
                weight: ${weight}
                nationality:"${nationality}"
                birth_type: "${birth_type}"
                drinking: ${drinking}
                  })
                  {
                    users{
                      user_name
                    }
                  }
              }
        """
st.title("Sanjeevan")

st.sidebar.markdown("# Main page ")

form = st.form(key="my_form")
name = form.text_input(label="Enter Name")
age = form.number_input(label="Enter Age")
sex = form.selectbox('Sex',('Male','Female'))
weight = form.number_input(label="Enter Weight")
nationality = form.selectbox('Nationality',('Indian','Non-Indian'))
birth_type = form.selectbox('Birth Type',('Normal','Cesarean'))
smoking = form.selectbox('Smoking',('true','false'))
drinking = form.selectbox('Drinking',('true','false'))
history_of_ibd = form.selectbox('History',('true','false'))

submitted = form.form_submit_button(label="Submit")

if submitted:
    requests.post(url, json={"query": query} )

0 Answers
Related