cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

GraphQL is returning [object Object]

I am using R/Shiny with Apollo and the Neo4j GraphQL Library. I am inferring my schema using this:

const inferAugmentedSchema = driver => {
  return inferSchema(driver).then(result => {
    console.log(result.typeDefs)
    return makeAugmentedSchema({
      typeDefs: result.typeDefs
    });
  });
};

The schema point of interest is:

type Skill {
   _id: Long!
   name: String!
   projects_in_need_of: [Project] @relation(name: "IN_NEED_OF", direction: IN)
}
type Project {
   _id: Long!
   description: String
   name: String!
}

My query is:

execute_query = function(query) {
        result <- conn$exec(Query$new()$query('link', query)$link)
        flat_result <- result %>% fromJSON(flatten = F)
        print(flat_result)
        result.df <- as.data.frame(flat_result[[1]])
        print(result.df)
        output$table <- DT::renderDataTable({result.df}, rownames = TRUE, filter = 'top', selection = 'single', extensions = 'Buttons')
    }
    
    # Run a query
    execute_query('

    query SampleQuery {
    Skill{
        name
        projects_in_need_of{
            name
            description
        }
      }
    }
    ')

The code will return the name of the skill, then it will return skill.projects_in_need_of instead of the name, and description. When it has a project to return, it returns [object Object]

I can't figure out if it is my query or not- I am new to this and using a template!

4 REPLIES 4

Does the query work if you just use graphql-playground or graphiql?

If you're just starting out you should consider moving to neo4j/graphql which is the new, officially supported library

If I copy and paste the query into the GraphQL playground API, it works! It must be something in my code. I don't know why it's not returning to the application.

The organization and team I belong to is using this template so I cannot move to the neo4j/graphql

I switched to the new driver and my query worked for two runs before it started returning the node object and not the attributes.

Can you add some log messages in between, not sure if the library has logging? Or step debug through it?