Resolver in graphql on relationHow should I write a resolver while using apollo graphql server backed by neo4j database?Graphql-Access arguments in child resolversUnrecognized arguments in graphql mutationReact Apollo using Named VariablegraphQL query give me null object in responseGraphql: completely change field type in schemaApollo / GraphQl - Type must be Input typeBuilding GraphQL Resolver to Return List of Strings — Receiving [object Object] Instead of StringsQuery component integrated inside functional componentApollo Server, Graphql - Must provide query string

What's the explanation for this joke about a three-legged dog that walks into a bar?

Can't understand how static works exactly

Why did modems have speakers?

Other than a swing wing, what types of variable geometry have flown?

Is it possible to build or embed the SMILES representation of compounds in 3D?

What is the best word describing the nature of expiring in a short amount of time, connoting "losing public attention"?

How could an engineer advance human civilization by time traveling to the past?

Monty Hall Problem with a Fallible Monty

What the purpose of the fuel shutoff valve?

What would be the side effects on the life of a person becoming indestructible?

Grid/table with lots of buttons

How may I shorten this shell script?

Why can't a country print its own money to spend it only abroad?

how to add 1 milliseconds on a datetime string?

Can 々 stand for a duplicated kanji with a different reading?

Is there a way to shorten this while condition?

Are symplectomorphisms of Weil–Petersson symplectic form induced from surface diffeomorphisms?

Invert Some Switches on a Switchboard

What is the spanish equivalent of "the boys are sitting"?

Reference request: mod 2 cohomology of periodic KO theory

Impact of throwing away fruit waste on a peak > 3200 m above a glacier

What exactly makes a General Products hull nearly indestructible?

Why must API keys be kept private?

Issue with ContourPlot



Resolver in graphql on relation


How should I write a resolver while using apollo graphql server backed by neo4j database?Graphql-Access arguments in child resolversUnrecognized arguments in graphql mutationReact Apollo using Named VariablegraphQL query give me null object in responseGraphql: completely change field type in schemaApollo / GraphQl - Type must be Input typeBuilding GraphQL Resolver to Return List of Strings — Receiving [object Object] Instead of StringsQuery component integrated inside functional componentApollo Server, Graphql - Must provide query string






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I would like to execute this request, to have all buckets with specific language :




buckets
id,
code,
language(id:1)
code





But I have this response :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language": "FR" <= Real value "EN"
,

"id": 4,
"language": "FR" <= Real value "EN"

]




I would like to have only the bucket with language id selected :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"


]




schema.js



import gql from 'apollo-server';

export const typeDefs = gql`

# Language
type Language
id: Int!
name: String
code: String
is_active: Boolean


# Bucket
type Bucket
id: Int!,
code: String
language(id: Int): Language


# query for types
type Query
buckets: [Bucket]


schema
query: Query

`;

export default typeDefs;


resolvers.js



import GraphQLDate from 'graphql-date';
import Bucket, Language from './connectors';

export const resolvers =
Date: GraphQLDate,
Query:
buckets(_, args)
return Bucket.findAll(
where: args,
order: [['created_at', 'DESC']],
);

,
Bucket:
language(bucket, id)
console.log('resolver id', id);
const where = id: bucket.fk_language_id ;

if (id)
where.id = id


return Language.findOne(
where: where,
);
,

;

export default resolvers;


connectors.js



...

// define language
const LanguageModel = db.define('language',
name : type: Sequelize.STRING,
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

// define bucket
const BucketModel = db.define('bucket',
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

BucketModel.belongsTo(LanguageModel,
foreignKey: 'fk_language_id'
);

LanguageModel.hasMany(BucketModel,
foreignKey: 'id'
);

...


My database is very simple, just two tables Language and Bucket.



Database



Language




id | name | code | is_active




Bucket




id | fk_language_id | code | created_at | updated_at




With this request :




buckets
id,
language
code





I have this result :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language":
"code": "EN"

,

"id": 4,
"language":
"code": "EN"


]











share|improve this question
























  • are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

    – masmerino
    Mar 26 at 17:09











  • Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

    – Amit Bhoyar
    Mar 26 at 17:10











  • @masmerino I updated my code with the simple request without specific id on language

    – Jérémie Chazelle
    Mar 26 at 17:12











  • let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

    – masmerino
    Mar 26 at 17:26











  • Prisma and grapql cool support filters by this way :)

    – masmerino
    Mar 26 at 17:27

















0















I would like to execute this request, to have all buckets with specific language :




buckets
id,
code,
language(id:1)
code





But I have this response :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language": "FR" <= Real value "EN"
,

"id": 4,
"language": "FR" <= Real value "EN"

]




I would like to have only the bucket with language id selected :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"


]




schema.js



import gql from 'apollo-server';

export const typeDefs = gql`

# Language
type Language
id: Int!
name: String
code: String
is_active: Boolean


# Bucket
type Bucket
id: Int!,
code: String
language(id: Int): Language


# query for types
type Query
buckets: [Bucket]


schema
query: Query

`;

export default typeDefs;


resolvers.js



import GraphQLDate from 'graphql-date';
import Bucket, Language from './connectors';

export const resolvers =
Date: GraphQLDate,
Query:
buckets(_, args)
return Bucket.findAll(
where: args,
order: [['created_at', 'DESC']],
);

,
Bucket:
language(bucket, id)
console.log('resolver id', id);
const where = id: bucket.fk_language_id ;

if (id)
where.id = id


return Language.findOne(
where: where,
);
,

;

export default resolvers;


connectors.js



...

// define language
const LanguageModel = db.define('language',
name : type: Sequelize.STRING,
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

// define bucket
const BucketModel = db.define('bucket',
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

BucketModel.belongsTo(LanguageModel,
foreignKey: 'fk_language_id'
);

LanguageModel.hasMany(BucketModel,
foreignKey: 'id'
);

...


My database is very simple, just two tables Language and Bucket.



Database



Language




id | name | code | is_active




Bucket




id | fk_language_id | code | created_at | updated_at




With this request :




buckets
id,
language
code





I have this result :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language":
"code": "EN"

,

"id": 4,
"language":
"code": "EN"


]











share|improve this question
























  • are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

    – masmerino
    Mar 26 at 17:09











  • Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

    – Amit Bhoyar
    Mar 26 at 17:10











  • @masmerino I updated my code with the simple request without specific id on language

    – Jérémie Chazelle
    Mar 26 at 17:12











  • let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

    – masmerino
    Mar 26 at 17:26











  • Prisma and grapql cool support filters by this way :)

    – masmerino
    Mar 26 at 17:27













0












0








0








I would like to execute this request, to have all buckets with specific language :




buckets
id,
code,
language(id:1)
code





But I have this response :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language": "FR" <= Real value "EN"
,

"id": 4,
"language": "FR" <= Real value "EN"

]




I would like to have only the bucket with language id selected :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"


]




schema.js



import gql from 'apollo-server';

export const typeDefs = gql`

# Language
type Language
id: Int!
name: String
code: String
is_active: Boolean


# Bucket
type Bucket
id: Int!,
code: String
language(id: Int): Language


# query for types
type Query
buckets: [Bucket]


schema
query: Query

`;

export default typeDefs;


resolvers.js



import GraphQLDate from 'graphql-date';
import Bucket, Language from './connectors';

export const resolvers =
Date: GraphQLDate,
Query:
buckets(_, args)
return Bucket.findAll(
where: args,
order: [['created_at', 'DESC']],
);

,
Bucket:
language(bucket, id)
console.log('resolver id', id);
const where = id: bucket.fk_language_id ;

if (id)
where.id = id


return Language.findOne(
where: where,
);
,

;

export default resolvers;


connectors.js



...

// define language
const LanguageModel = db.define('language',
name : type: Sequelize.STRING,
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

// define bucket
const BucketModel = db.define('bucket',
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

BucketModel.belongsTo(LanguageModel,
foreignKey: 'fk_language_id'
);

LanguageModel.hasMany(BucketModel,
foreignKey: 'id'
);

...


My database is very simple, just two tables Language and Bucket.



Database



Language




id | name | code | is_active




Bucket




id | fk_language_id | code | created_at | updated_at




With this request :




buckets
id,
language
code





I have this result :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language":
"code": "EN"

,

"id": 4,
"language":
"code": "EN"


]











share|improve this question
















I would like to execute this request, to have all buckets with specific language :




buckets
id,
code,
language(id:1)
code





But I have this response :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language": "FR" <= Real value "EN"
,

"id": 4,
"language": "FR" <= Real value "EN"

]




I would like to have only the bucket with language id selected :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"


]




schema.js



import gql from 'apollo-server';

export const typeDefs = gql`

# Language
type Language
id: Int!
name: String
code: String
is_active: Boolean


# Bucket
type Bucket
id: Int!,
code: String
language(id: Int): Language


# query for types
type Query
buckets: [Bucket]


schema
query: Query

`;

export default typeDefs;


resolvers.js



import GraphQLDate from 'graphql-date';
import Bucket, Language from './connectors';

export const resolvers =
Date: GraphQLDate,
Query:
buckets(_, args)
return Bucket.findAll(
where: args,
order: [['created_at', 'DESC']],
);

,
Bucket:
language(bucket, id)
console.log('resolver id', id);
const where = id: bucket.fk_language_id ;

if (id)
where.id = id


return Language.findOne(
where: where,
);
,

;

export default resolvers;


connectors.js



...

// define language
const LanguageModel = db.define('language',
name : type: Sequelize.STRING,
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

// define bucket
const BucketModel = db.define('bucket',
code : type: Sequelize.STRING,
is_active: type: Sequelize.BOOLEAN
);

BucketModel.belongsTo(LanguageModel,
foreignKey: 'fk_language_id'
);

LanguageModel.hasMany(BucketModel,
foreignKey: 'id'
);

...


My database is very simple, just two tables Language and Bucket.



Database



Language




id | name | code | is_active




Bucket




id | fk_language_id | code | created_at | updated_at




With this request :




buckets
id,
language
code





I have this result :




"data":
"buckets": [

"id": 1,
"language":
"code": "FR"

,

"id": 2,
"language":
"code": "FR"

,

"id": 3,
"language":
"code": "EN"

,

"id": 4,
"language":
"code": "EN"


]








graphql sequelize.js apollo apollo-server






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 17:40







Jérémie Chazelle

















asked Mar 26 at 15:04









Jérémie ChazelleJérémie Chazelle

1,02417 silver badges42 bronze badges




1,02417 silver badges42 bronze badges












  • are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

    – masmerino
    Mar 26 at 17:09











  • Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

    – Amit Bhoyar
    Mar 26 at 17:10











  • @masmerino I updated my code with the simple request without specific id on language

    – Jérémie Chazelle
    Mar 26 at 17:12











  • let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

    – masmerino
    Mar 26 at 17:26











  • Prisma and grapql cool support filters by this way :)

    – masmerino
    Mar 26 at 17:27

















  • are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

    – masmerino
    Mar 26 at 17:09











  • Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

    – Amit Bhoyar
    Mar 26 at 17:10











  • @masmerino I updated my code with the simple request without specific id on language

    – Jérémie Chazelle
    Mar 26 at 17:12











  • let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

    – masmerino
    Mar 26 at 17:26











  • Prisma and grapql cool support filters by this way :)

    – masmerino
    Mar 26 at 17:27
















are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

– masmerino
Mar 26 at 17:09





are you pretty sure this is happening when you include the ID in the query? ``` if (id) where.id = id ```

– masmerino
Mar 26 at 17:09













Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

– Amit Bhoyar
Mar 26 at 17:10





Are you getting "id" in your resolver ? Because i don't see any "input" in schema.

– Amit Bhoyar
Mar 26 at 17:10













@masmerino I updated my code with the simple request without specific id on language

– Jérémie Chazelle
Mar 26 at 17:12





@masmerino I updated my code with the simple request without specific id on language

– Jérémie Chazelle
Mar 26 at 17:12













let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

– masmerino
Mar 26 at 17:26





let's do a quick test: could you change your query to it: buckets(filter: languaje: id: 1) id, language code

– masmerino
Mar 26 at 17:26













Prisma and grapql cool support filters by this way :)

– masmerino
Mar 26 at 17:27





Prisma and grapql cool support filters by this way :)

– masmerino
Mar 26 at 17:27












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360369%2fresolver-in-graphql-on-relation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360369%2fresolver-in-graphql-on-relation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현