LOGIN
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link
QUESTION
Open

Fixing Postgres functions in graphql schema

Hey Ranjan (and community)…I am working on graphQL backend. I’m not entirely sure you even need to know graphQL to fix this issue. Basically in the schema.ts file (https://github.com/sreubenstone/graphqlreactapp/blob/master/schema/schema.ts) in the RESOLVE functions this is where you connect to postgres and send queries. Take a look at how I’m setting this up. One primary issue I am having is that I am not getting a response that graphQL can read. Do I need to modify the results of the response into something GraphQL can understand? I know this seems obvious but I was executing this graphql query and it was actually partially working. And it previous tutorials it does not make it clear what “form” to leave the response. This may be a very noob question but as a new coder it’s confusing to understand what the “shape of a response” should look like and how to interface it with the technology receiving the response (graphql).

2 likes 
Like
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link

If you run this locally and install dependencies (npm i) you can hit http://localhost:4000/graphql and actually pass in the graphQL mutations. I have two write now…

{

  messages  {
    id
    message
  }

}

and

mutation {
  
  addMessage (message: "hello world") {
    message
    
  }

}

Like
1 like 
Award Contribution
Ranjan Dailata
92
Community Expert
Solution Architect. Collaborizm Roundtable.
 · MysuruIndia
Share
Report
Get Link

Hey Steven Reubenstone take a look into the below article to understand on how one can build the query response for graphql.

You need to return response in a graphql compatible format only.

https://blog.hasura.io/working-with-schemaless-data-with-graphql-on-postgres-574a1ee2e87f

My suggestion for noob is to first have a basic understanding of graphql, work on samples and then slowly get into the root of graphql to work on complex projects/products.

Like
2 likes 
Award Contribution
Ranjan Dailata
92
Community Expert
Solution Architect. Collaborizm Roundtable.
 · MysuruIndia
Share
Report
Get Link

Try to modify your code as mentioned in the below article. I am sure, it will work.

https://blog.cloudboost.io/postgresql-and-graphql-2da30c6cde26

Like
1 like 
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link

Thanks ranjan will take a look

Like
2 likes 
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link

Ooo haha this girls code is bugged rob showed me

Like
1 like 
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
Chat with us!
Help
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard