Filter Github issues by author using their graphql API - api

I'm trying to figure out how to get the list of issues by author. I can get the list of issues but I don't know is how to filter 'by author'.
The following returns a list of issues from the repo "Hello-World" of the owner "octocat". What I want to do is to filter issue author: "yosuke-furukawa" or any other author. How to do that?
You may try it out at the explorer.
repository(owner:"octocat", name:"Hello-World") {
issues(last:20, states:CLOSED) {
edges {
node {
bodyText
author{
login
}
}
}
}
}
}

To get the list of issues created by a specific author, you can query for objects of type ISSUE, adding the repository information and the author name in the query string:
query {
search(
type: ISSUE,
query: """
repo:octocat/Hello-World
author:yosuke-furukawa
state:closed
""",
last: 20
) {
edges {
node {
... on Issue {
id
title
bodyText
author {
login
}
}
}
}
}
}
The full syntax for querying issues can be found here:
https://help.github.com/en/articles/searching-issues-and-pull-requests

Related

Difficulty parsing JSON 3 levels deep

React native is having difficulties parsing JSON three levels deep. The object is structured like so:
data: {
post: {
user1: {
name: "user name"
}
}
}
data.post.user1 works fine and returns an object; however, when I try to get the name parameter react-native throws the following error:
undefined is not an object (evaluating 'data.post.user1.name')
Is this a known issue? I am getting data from response.json in a fetch call. EDIT: Object.keys(data.post.user1) returns the same error.
First, declare it in a variable and then make an object :
const data = {
date:{
post: {
user1: {
name: "user name"
}
}}}
Get the value like this :
<Text>{data.date.post.user1.name}</Text>

How To Get Particular Security Advisory Repository in Graphql

I have Tried
I have tried this code
`# Type queries into this side of the screen, and you will
# see intelligent typeaheads aware of the current GraphQL type schema,
# live syntax, and validation errors highlighted within the text.
# We'll get you started with a simple query showing your username!
query {
securityAdvisories(orderBy: {field: PUBLISHED_AT, direction: DESC}, first: 2) {
nodes {
description
ghsaId
summary
publishedAt
}
}
}
And got the below response
{
"data": {
"securityAdvisories": {
"nodes": [
{
"description": "In Symfony before 2.7.51, 2.8.x before 2.8.50, 3.x before 3.4.26, 4.x before 4.1.12, and 4.2.x before 4.2.7, when service ids allow user input, this could allow for SQL Injection and remote code execution. This is related to symfony/dependency-injection.",
"ghsaId": "GHSA-pgwj-prpq-jpc2",
"summary": "Critical severity vulnerability that affects symfony/dependency-injection",
"publishedAt": "2019-11-18T17:27:31Z"
},
{
"description": "Tapestry processes assets `/assets/ctx` using classes chain `StaticFilesFilter -> AssetDispatcher -> ContextResource`, which doesn't filter the character `\\`, so attacker can perform a path traversal attack to read any files on Windows platform.",
"ghsaId": "GHSA-89r3-rcpj-h7w6",
"summary": "Moderate severity vulnerability that affects org.apache.tapestry:tapestry-core",
"publishedAt": "2019-11-18T17:19:03Z"
}
]
}
}
}
But i want to get the response for specific security advisory like this
i.e i want to get graphql response for specific id for below example url ID is GHSA-wmx6-vxcf-c3gr
Thanks!
The simplest way would be to use the securityAdvisory() query.
query {
securityAdvisory(ghsaId: "GHSA-wmx6-vxcf-c3gr") {
ghsaId
summary
}
}
If you need to use the securityAdvisories() query for some reason, you simply have to add an identifier:. The following query should get the distinct entry for GHSA-wmx6-vxcf-c3gr.
query {
securityAdvisory(ghsaId: "GHSA-wmx6-vxcf-c3gr") {
ghsaId
summary
}
}

How to fetch GitHub branch names using GraphQL

Using GitHub GraphQL API (v.4) I would like to get all the branch names existing on a given repository.
My attempt
{
repository(name: "my-repository", owner: "my-account") {
... on Ref {
name
}
}
}
returns error:
{'data': None, 'errors': [{'message': "Fragment on Ref can't be spread inside Repository", 'locations': [{'line': 4, 'column': 13}]}]}
Here's how to retrieve 10 branches from a repo:
{
repository(name: "git-point", owner: "gitpoint") {
refs(first: 10, , refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
PS: You usually use spread when dealing with an Union type (like IssueTimeline for example, which is composed of different kind of objects, so you can spread on a particular object type to query specific fields.
You might need to use pagination to get all branches

GraphQL gql Syntax Error: Expected Name, found }

I'm attempting to set up Apollo GraphQL support in a new React project, but when I try to compile a query using gql I keep receiving the error:
Syntax Error: Expected Name, found }
This is generated by the following code:
import gql from 'graphql-tag'
const query = gql`
{
user(id: 5) {
firstName
lastName
}
}
`
console.log(query)
I'm basing this code off the example code found here: https://github.com/apollographql/graphql-tag
What is the Name referred to in the error message? Does anyone know what I'm doing wrong here?
This error occurs mostly when there are unclosed curly braces or when some fields are not properly defined while calling the query.
The accepted answer didn't solve my issue. Instead, it worked if you remove the initial curly brackets.
The query should look like this instead:
const query=gql`
user(id: 5) {
firstName
lastName
}
`
The causes could be:
you are adding a "()" at the beginning for no reason
you need to add more 'nested' parameters.
Especially if you are using an online GraphiQL editor. Examples:
1- Wrong code (extra parenthesis)
{
allFilms() {
films {
title
}
}
}
2- Wrong code (more parameters need it eg: title)
{
allFilms {
films {
}
}
}
3- Correct code
{
allFilms {
films {
title
}
}
}
GraphQLError: Syntax Error: Expected Name, found "$".
One more example of a similar error (For other users).
theErrorIsHere (Could be extra ( or { before the $varName) added before $speakerId
Error code:
const FEATURED_SPEAKER = gql`
mutation markFeatured($speakerId: ID!, $featured: Boolean!){
markFeatured(speaker_id: theErrorIsHere$speakerId , featured: $featured){
id
featured
}
}
`;
Correct code:
const FEATURED_SPEAKER = gql`
mutation markFeatured($speakerId: ID!, $featured: Boolean!){
markFeatured(speaker_id: $speakerId , featured: $featured){
id
featured
}
}
`;
I'm not 100% sure what the root of my problem was, but moving all the query code into a separate es6 module fixed the issue. There must have been some kind of contamination from the surrounding code. For reference my query was embedded within a React component.
This works:
import gql from 'graphql-tag'
const query = gql`
{
user(id: 5) {
firstName
lastName
}
}
`
export default query
Another cause for this error: you are referencing a type that is defined further down. Move the type you are referencing up.
For example:
type Launch {
rocket: Rocket
}
type Rocket {
name: String
}
will throw an error, as Launch references Rocket before Rocket is defined.
The corrected code:
type Rocket {
name: String
}
type Launch {
rocket: Rocket
}
In my case, I got the error simply because I'm adding : which I shouldn't have done.
e.g:
const query = `
query($id: String!) {
getUser(id: $id) {
user: {
id
name
email
createdAt
}
}
}
`
If you pay close attention to line 4 of the code above you'll realize that I added : after the user before the curly brace, then I began to list the user's data I wanna query and THAT WAS EXACTLY WHERE THE ERROR WAS!
Removing the : solve the issue!
It should be:
user {
id
name
...
}
In NestJS framework, this error happened to me because I defiled GraphQL field in my schema.graphql file as:
lastUpdated(): Date
Instead it should be just
lastUpdated: Date
(it doesn't take any argument)
I was receiving a similar error server side:
GraphQLError: Syntax Error: Expected Name, found ]
I realized the cause in my case was a type definition with an empty array.
This breaks:
type Settings {
requires: []
}
But this works:
type Settings {
requires: [String]
}
I had this problem and the cause was a string value with double-quotes inside double-quotes, like so: "this "is" bad".
In my case I got the error because of the following:
const GET_POSTS_OF_AUTHOR = gql`
query GetPostsOfAuthor($authorId: Int!) {
postsOf($authorId: Int!) {
id
title
}
}
`;
When it should have been:
const GET_POSTS_OF_AUTHOR = gql`
query GetPostsOfAuthor($authorId: Int!) {
postsOf(authorId: $authorId) {
id
title
}
}
`;
erroneously thought $authorId passed through identically to the function call instead of setting a property inside the function call.
This can happen if you use gql from #clinet/apollo and in the backticks you try to inject dynamic js value. Remove it and replace with normal scalar and it will fix your issue.
example:
${SOME_MAX_VALUE} -> 20
On ny side the error was caused by extra {} Curly braces. Solved by just removing them.
I was getting the same error. In my case putting the id inside double quote solved the issue as the type of id required string value.
{
product(id: "${id}") {
name
}
}
Posting here in case anyone else had this problem but you also get this error if you accidentally make your query look like json with colons (:).
ex:
data {
property {
key: {
deepKey
}
}
}
will give the same error from GQL compile

MobileFirst 6.3: Could not find method org.json.JSONException.<init>

IBM MobileFirst 6.3.0 in Windows
I have few warning and exceptions when I work with Json Store.
Can that be ignored or any fix is available, Since I am using latest MobileFirst studio installed from Eclipse Market place
JSON STORE Code:
var jsonStoreObject = { };
jsonStoreObject.collectionName = 'people';
jsonStoreObject.collections = {
people : {
searchFields : {name: 'string', age: 'integer'}
}
};
jsonStoreObject.options = {
username : "Hello",
password : "123"
};
function openJSON(){
WL.JSONStore.init(jsonStoreObject.collections, jsonStoreObject.options)
.then(function(data) {
WL.Logger.info("After Init::"+ JSON.stringify(data));
return WL.JSONStore.get(jsonStoreObject.collectionName).findAll();
})
.then(function(findAllResult) {
WL.Logger.info("findAllResult::"+ JSON.stringify(findAllResult));
if (findAllResult.length == 0) {
var data = [{name: 'carlos', age: 10}];
return WL.JSONStore.get(jsonStoreObject.collectionName).add(data);
}
})
.fail(function (errorObject) {
console.log("Json Failure:: " + WL.JSONStore.getErrorMessage(errorObject));
});
}
Exceptions/Warnings:
03-18 05:23:17.332: I/dalvikvm(1669): Could not find method
org.json.JSONException., referenced from method
com.worklight.androidgap.jsonstore.security.DPKBean.
03-18 05:23:17.332: W/dalvikvm(1669): VFY: unable to resolve direct method
34098: Lorg/json/JSONException;. (Ljava/lang/Throwable;)V
Also, when I call the openJSON() for the first time I used to get following log like database already exists.
03-18 06:50:05.518: D/JSONSTORE(1053): JSONStoreLogger.logDebug in
JSONStoreLogger.java:174 :: provisioning database "people" (already
exists: false)
The first one is just a warning, and it always shows up. It does not affect anything. The second one is just a debug message telling you if the collection you are creating was previously created or not; if it had already existed, it would just return that one, and say "already exists:true".
Neither of them affect the execution, so you don't have to worry about them.