cannot pass value to parameter typed as ID
See original GitHub issueIs it anyhow possible to pass a value to an ID typed parameter like below ?
I am trying to get repository information from GitHub. Therefore I created a parameterized query that expects $id of type ID!
Whenever I try to pass an ID Value like “MDEwOlJlcG9zaXRvcnk1NDc4MjE2MQ==” I get this:
Error: GraphQL error: Variable id of type ID! was provided invalid value
When I switch the parameter type from ID to String I get:
Error: GraphQL error: Type mismatch on variable $id and argument id (String / ID!)
Here’s the query definition:
private repositoryByIdQuery: any = gql`
query repositoryById($id: ID!){
node(id: $id){
...repositoryFragment
}
}
fragment repositoryFragment on Repository {
id
description
isPrivate
name
}
`
Here’s the executing code:
public getById(id: string): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
this.githubClient.query({
query: this.repositoryByIdQuery,
variables:{
id: id
}
}).then(
({loading, data}) => {
if(!loading){
console.log(data);
resolve(data);
}
},(reason) => {
console.log("hello from rejected"+ reason);
reject(reason);
});
}
)
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top Results From Across the Web
Unable to Pass Value through Parameter ID - SAP Community
Hi , I Cant able to Pass value from my zreport to Tcode "co40 " , Except "PLNUM ... Order type : Field...
Read more >Passing variable name as id - javascript - Stack Overflow
You cannot pass what doesn't exist. To solve this, generate a name and an id to use. Also in your selectMainBrand function you...
Read more >Parameters - AWS CloudFormation
Use parameters to pass values to your template when creating or updating a stack so that you can customize each stack deployment.
Read more >The Go Programming Language Specification
It is an error if the constant value cannot be represented as a value of the respective type. If the type is a...
Read more >Function pass by value vs. pass by reference
I will call what you are passing in a to a function the actual parameters, and where you ... This function, which swaps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shtse8
If your schema looks something like this:
You can execute your query like this:
Make sure you use exact same
type
in query that you used while defining your schema, otherwise the GraphQL parser will yell at you.Let me know if this helps. 😃
Just answered it myself - I was querying with
query repositoryById($id: String!){
instead ofquery repositoryById($id: ID!){