Skip to content

fetching issue in graphql-gun  #31

@siddhudhangar

Description

@siddhudhangar

i am trying to fetch the data from gun db with the help of graphql-gun. but i got zero result from gundb. i referred following url to query gun db i.e https://github.com/brysgo/graphql-gun. i tested with react and without react but still same problem occurred. I tried below code

const graphqlGun = require('graphql-gun');
const Gun = require('gun');
const gql = require('graphql-tag')

const gun = Gun();

const fish = gun.get('fish');
fish.put({red: {name: 'Frank'}});
fish.put({blue: {name: 'John'}});
const friends = fish.get('friends');
const dori = fish.get('dori')
const martin = fish.get('martin')
const nemo = fish.get('nemo')
dori.put({ name: 'Dori', favoriteColor: 'blue' });
martin.put({ name: 'Martin', favoriteColor: 'orange' });
nemo.put({ name: 'Nemo', favoriteColor: 'gold' });
friends.set(dori);
friends.set(martin);
friends.set(nemo);

const myQuery = gql`{
fish {
red {
name
}

blue {
  _chain
}

friends(type: Set) {
  name
  favoriteColor
}

}
}`;

graphqlGun(myQuery, gun).then(function(results) {
console.log('results: ', results);
});

Expected Output:
{
fish: {
red: {
name: 'Frank' // the name you set on the red fish
},
blue: {
_chain: <Gun.chain> // reference to gun chain at blue node
},
friends: [
{ name: 'Dori', favoriteColor: 'blue' },
{ name: 'Martin', favoriteColor: 'orange' },
{ name: 'Nemo', favoriteColor: 'gold' }
]
}
}

but i got empty results from gundb

{
fish: {
red: { },
blue: { },
friends: [ ]
}
}

i ran above program using node i.e node test.js
so can anybody help me to how to fetch the data of gundb throgh graphql-gun basically i wanted to a query to fetch the gundb data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions