GraphQL query returning null fieldsHow to check empty/undefined/null string in JavaScript?How can I get query string values in JavaScript?event.preventDefault() vs. return falseHow to determine if variable is 'undefined' or 'null'?Is there a standard function to check for null, undefined, or blank variables in JavaScript?How to retrieve POST query parameters?How to get GET (query string) variables in Express.js on Node.js?Why does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?npm WARN package.json: No repository field
What city and town structures are important in a low fantasy medieval world?
How to become an Editorial board member?
Was Tyrion always a poor strategist?
Is being an extrovert a necessary condition to be a manager?
What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?
Farthing / Riding
Warped chessboard
Is it wise to pay off mortgage with 401k?
How to play vs. 1.e4 e5 2.Nf3 Nc6 3.Bc4 d6?
What are the domains of the multiplication and unit morphisms of a monoid object?
Is there a realtime, uncut video of Saturn V ignition through tower clear?
Are CTRL+C and <esc> the same?
How would a physicist explain this starship engine?
Department head said that group project may be rejected. How to mitigate?
How to safely discharge oneself
Why does an injection from a set to a countable set imply that set is countable?
How to tease a romance without a cat and mouse chase?
How to prove the emptiness of intersection of two context free languages is undecidable?
How do you cope with rejection?
1950s or earlier book with electrical currents living on Pluto
Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?
Does science define life as "beginning at conception"?
How to counter "I don't like your tone" in a work conversation?
Simple Arithmetic Puzzle 7. Or is it?
GraphQL query returning null fields
How to check empty/undefined/null string in JavaScript?How can I get query string values in JavaScript?event.preventDefault() vs. return falseHow to determine if variable is 'undefined' or 'null'?Is there a standard function to check for null, undefined, or blank variables in JavaScript?How to retrieve POST query parameters?How to get GET (query string) variables in Express.js on Node.js?Why does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?npm WARN package.json: No repository field
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am writing a GraphQL schema for data with a scores array of different sizes. The data is for quiz scores. The quiz varies in size based on how many people took the quiz.
When I submit the query, I get null back for "answered" and "correct".
I want to get back all the scores for each quiz. I wrote the schema with a ScoreType that has the "answered" and "correct" fields. I'm not sure if the schema is the problem or how I am querying the data.
Here is the JSON file for the quizzes
[
"length": "15",
"average": "77",
"created_at": "2019-02-01",
"course": "MATH311",
"scores": [
"correct": "12",
"answered": "14"
,
"correct": "9",
"answered": "15"
]
,
"length": "25",
"average": "17",
"created_at": "2019-02-03",
"course": "MATH301",
"scores": [
"correct": "11",
"answered": "14"
,
"correct": "17",
"answered": "25"
,
"correct": "20",
"answered": "22"
,
"correct": "18",
"answered": "24"
]
]
Here is the GraphQL schema
const Quiz = new GraphQLObjectType(
name: "Launch",
fields: () => (
length: type: GraphQLInt,
average: type: GraphQLInt,
created_at: type: GraphQLString,
course: type: GraphQLString,
scores: type: ScoreType
)
)
const ScoreType = new GraphQLObjectType(
name: "Answer",
fields: () => (
correct: type: GraphQLInt,
answered: type: GraphQLString,
)
)
const RootQuery = new GraphQLObjectType(
name: 'RootQueryType',
fields:
polls:
type: new GraphQLList(PollType),
resolve(parent, args)
return axios.get(POLL_URL)
.then(res => res.data);
)
Here is the query
quiz_data
scores
correct
answered
Here is what it returns
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
javascript node.js express graphql
add a comment |
I am writing a GraphQL schema for data with a scores array of different sizes. The data is for quiz scores. The quiz varies in size based on how many people took the quiz.
When I submit the query, I get null back for "answered" and "correct".
I want to get back all the scores for each quiz. I wrote the schema with a ScoreType that has the "answered" and "correct" fields. I'm not sure if the schema is the problem or how I am querying the data.
Here is the JSON file for the quizzes
[
"length": "15",
"average": "77",
"created_at": "2019-02-01",
"course": "MATH311",
"scores": [
"correct": "12",
"answered": "14"
,
"correct": "9",
"answered": "15"
]
,
"length": "25",
"average": "17",
"created_at": "2019-02-03",
"course": "MATH301",
"scores": [
"correct": "11",
"answered": "14"
,
"correct": "17",
"answered": "25"
,
"correct": "20",
"answered": "22"
,
"correct": "18",
"answered": "24"
]
]
Here is the GraphQL schema
const Quiz = new GraphQLObjectType(
name: "Launch",
fields: () => (
length: type: GraphQLInt,
average: type: GraphQLInt,
created_at: type: GraphQLString,
course: type: GraphQLString,
scores: type: ScoreType
)
)
const ScoreType = new GraphQLObjectType(
name: "Answer",
fields: () => (
correct: type: GraphQLInt,
answered: type: GraphQLString,
)
)
const RootQuery = new GraphQLObjectType(
name: 'RootQueryType',
fields:
polls:
type: new GraphQLList(PollType),
resolve(parent, args)
return axios.get(POLL_URL)
.then(res => res.data);
)
Here is the query
quiz_data
scores
correct
answered
Here is what it returns
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
javascript node.js express graphql
add a comment |
I am writing a GraphQL schema for data with a scores array of different sizes. The data is for quiz scores. The quiz varies in size based on how many people took the quiz.
When I submit the query, I get null back for "answered" and "correct".
I want to get back all the scores for each quiz. I wrote the schema with a ScoreType that has the "answered" and "correct" fields. I'm not sure if the schema is the problem or how I am querying the data.
Here is the JSON file for the quizzes
[
"length": "15",
"average": "77",
"created_at": "2019-02-01",
"course": "MATH311",
"scores": [
"correct": "12",
"answered": "14"
,
"correct": "9",
"answered": "15"
]
,
"length": "25",
"average": "17",
"created_at": "2019-02-03",
"course": "MATH301",
"scores": [
"correct": "11",
"answered": "14"
,
"correct": "17",
"answered": "25"
,
"correct": "20",
"answered": "22"
,
"correct": "18",
"answered": "24"
]
]
Here is the GraphQL schema
const Quiz = new GraphQLObjectType(
name: "Launch",
fields: () => (
length: type: GraphQLInt,
average: type: GraphQLInt,
created_at: type: GraphQLString,
course: type: GraphQLString,
scores: type: ScoreType
)
)
const ScoreType = new GraphQLObjectType(
name: "Answer",
fields: () => (
correct: type: GraphQLInt,
answered: type: GraphQLString,
)
)
const RootQuery = new GraphQLObjectType(
name: 'RootQueryType',
fields:
polls:
type: new GraphQLList(PollType),
resolve(parent, args)
return axios.get(POLL_URL)
.then(res => res.data);
)
Here is the query
quiz_data
scores
correct
answered
Here is what it returns
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
javascript node.js express graphql
I am writing a GraphQL schema for data with a scores array of different sizes. The data is for quiz scores. The quiz varies in size based on how many people took the quiz.
When I submit the query, I get null back for "answered" and "correct".
I want to get back all the scores for each quiz. I wrote the schema with a ScoreType that has the "answered" and "correct" fields. I'm not sure if the schema is the problem or how I am querying the data.
Here is the JSON file for the quizzes
[
"length": "15",
"average": "77",
"created_at": "2019-02-01",
"course": "MATH311",
"scores": [
"correct": "12",
"answered": "14"
,
"correct": "9",
"answered": "15"
]
,
"length": "25",
"average": "17",
"created_at": "2019-02-03",
"course": "MATH301",
"scores": [
"correct": "11",
"answered": "14"
,
"correct": "17",
"answered": "25"
,
"correct": "20",
"answered": "22"
,
"correct": "18",
"answered": "24"
]
]
Here is the GraphQL schema
const Quiz = new GraphQLObjectType(
name: "Launch",
fields: () => (
length: type: GraphQLInt,
average: type: GraphQLInt,
created_at: type: GraphQLString,
course: type: GraphQLString,
scores: type: ScoreType
)
)
const ScoreType = new GraphQLObjectType(
name: "Answer",
fields: () => (
correct: type: GraphQLInt,
answered: type: GraphQLString,
)
)
const RootQuery = new GraphQLObjectType(
name: 'RootQueryType',
fields:
polls:
type: new GraphQLList(PollType),
resolve(parent, args)
return axios.get(POLL_URL)
.then(res => res.data);
)
Here is the query
quiz_data
scores
correct
answered
Here is what it returns
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
"data":
"quiz_data": [
"correct": null,
"answered": null
]
,
javascript node.js express graphql
javascript node.js express graphql
edited Mar 23 at 20:17
jhaywoo8
asked Mar 23 at 19:36
jhaywoo8jhaywoo8
1781512
1781512
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Solved it myself. Instead of doing this..
scores: type: ScoreType
you have to wrap ScoreType in GraphQLList like this ..
scores: type: GraphQLList(ScoreType)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317617%2fgraphql-query-returning-null-fields%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solved it myself. Instead of doing this..
scores: type: ScoreType
you have to wrap ScoreType in GraphQLList like this ..
scores: type: GraphQLList(ScoreType)
add a comment |
Solved it myself. Instead of doing this..
scores: type: ScoreType
you have to wrap ScoreType in GraphQLList like this ..
scores: type: GraphQLList(ScoreType)
add a comment |
Solved it myself. Instead of doing this..
scores: type: ScoreType
you have to wrap ScoreType in GraphQLList like this ..
scores: type: GraphQLList(ScoreType)
Solved it myself. Instead of doing this..
scores: type: ScoreType
you have to wrap ScoreType in GraphQLList like this ..
scores: type: GraphQLList(ScoreType)
answered Mar 23 at 20:27
jhaywoo8jhaywoo8
1781512
1781512
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317617%2fgraphql-query-returning-null-fields%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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