in Education by
I am trying to fetch some data from the GitHub GraphQL but I get a GaphQLError. I have tried the same query on the developer section of github and it works. Anyone know what is the problem with it? issueQuery = gql` query search(first: 10, type: ISSUE, query: "repo:angular/angular is:issue state:open") { issueCount edges { node { ... on Issue { createdAt title body url comments(first: 10) { nodes { body } } } } } } `; Error Stack Trace: "GraphQLError: Syntax Error: Expected $, found Name "first" at syntaxError (http://localhost:4200/vendor.js:70270:10) at expect (http://localhost:4200/vendor.js:75154:67) at parseVariable (http://localhost:4200/vendor.js:73984:3) at parseVariableDefinition (http://localhost:4200/vendor.js:73970:15) at many (http://localhost:4200/vendor.js:75222:16) at parseVariableDefinitions (http://localhost:4200/vendor.js:73959:82) at parseOperationDefinition (http://localhost:4200/vendor.js:73926:26) at parseExecutableDefinition (http://localhost:4200/vendor.js:73881:16) at parseDefinition (http://localhost:4200/vendor.js:73845:16) at many (http://localhost:4200/vendor.js:75222:16)" New Error Stack Trace when adding $ before the parameters: "GraphQLError: Syntax Error: Expected Name, found Int "10" at syntaxError (http://localhost:4200/vendor.js:70270:10) at expect (http://localhost:4200/vendor.js:75154:67) at parseName (http://localhost:4200/vendor.js:73809:15) at parseNamedType (http://localhost:4200/vendor.js:74385:11) at parseTypeReference (http://localhost:4200/vendor.js:74364:12) at parseVariableDefinition (http://localhost:4200/vendor.js:73971:83) at many (http://localhost:4200/vendor.js:75222:16) at parseVariableDefinitions (http://localhost:4200/vendor.js:73959:82) at parseOperationDefinition (http://localhost:4200/vendor.js:73926:26) at parseExecutableDefinition (http://localhost:4200/vendor.js:73881:16)" JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Don't confuse the operation with the actual field being queried. The syntax should look like this: operationType [operationName] [variableDefinitions] { selectionSet } where operationType is one of query, mutation or subscription, operationName is an arbitrary name for your operation used in debugging, variableDefinitions are type definitions for any variables you reference inside the operation, and selectionSet is one or more fields you're actually querying. In this case, search is a field we're querying, so it should not be proceeded by the query keyword. This works fine, provided you're authenticated: query OptionalName { search(first: 10, type: ISSUE, query: "repo:angular/angular is:issue state:open") { issueCount edges { # more fields } } } If the operation type is query, you can omit the query keyword altogether. This is called "query shorthand": { search(first: 10, type: ISSUE, query: "repo:angular/angular is:issue state:open") { issueCount edges { # more fields } } } If you use variables, define them inside parentheses beside your operation. Variable names are arbitrary, but by convention we use the input field names they will be used in: query OptionalName ($first: Int, type: SearchType!, $query: String! ) { search(first: $first, type: $type, query: $query) { issueCount edges { # more fields } } }

Related questions

0 votes
    We have db collection which is little complicated. Many of our keys are JSON objects where fields aren't ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    When I'm making a request to my backend through a mutation like that: mutation{ resetPasswordByToken(token:" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    How can I transform QraphQl query to HTTP get request for example http://localhost:4000/? query GetClient { ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    The apollo basic example at https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Implementing- ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I've been trying to send a cookie back to the client from the server. I get the response data ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I'm trying to query two JSON files that I put in a src/data directory. I installed gatsby- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to query two JSON files that I put in a src/data directory. I installed gatsby- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    We have a SQUID reverse proxy and a MOSS 2007 portal. All sites are using NTLM. We cannot get it ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I am working in an graphql application where I have to send custom error object / message in json ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    can anyone please help me out for this question Write a program to create two threads, so one thread will print ... between 11 to 20. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    can anyone please help me out for this question Write a program to create two threads, so one thread will print ... between 11 to 20. Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    I have an graphql/apollo-server/graphql-yoga endpoint. This endpoint exposes data returned from a database ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to use aws container service as per the documentation in http://docs.aws.amazon.com/AmazonECS/latest/ ... in a console? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I'm trying to deploy a Docker container image to AWS using ECS, but the EC2 instance is not being created. I have ... , to begin with!! Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    If you are running a web application or a user is going to fill it out and query data, the best option is to ... . Health monitoring probes C. A load balancer D. A traffic manager...
asked Nov 21, 2022 in Education by JackTerrance
...