createProject mutation not working?


#1

Am I doing something wrong?

Mutation:

mutation createProject($input: Object!) {
    createProject(input: $input) {
      clientMutationId
    }
  }

where $input is defined as:

{
      input: {
        body: this.body
      }
    }

I get this response:

{“data”:null,“errors”:[{“message”:“Something went wrong while executing your query. This is most likely a GitHub bug. Please include “8D8A0C94:2BF7:AB7A53:5849519D” when reporting this issue.”}]}

Am I doing something wrong? Documentation is not very clear about mutating data, so I’m not sure if it’s me or actual API.

Thanks.


#2

I’m also struggling to use the createProject mutation.

Maybe you should add a name and ownerId (which are required fields to create a project according to the documentation).

But even with that, I get an error. Here’s my query (full inline, without parameters):

mutation {
  createProject(
    input:{
      name:"test name",
      ownerId:"MDQ6VXNlcjEwMTA0NTUx",
      body: "test body"
    }
  ) {
    clientMutationId
    project {
      id
    }
  }
}

And here’s the response I have:

{
  "data": {
    "createProject": null
  },
  "errors": [
    {
      "message": "Could not resolve to a node with the global id of 'MDQ6VXNlcjEwMTA0NTUx'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createProject"
      ]
    }
  ]
}

The ownerId I use comes from this query,I’ve also checked that this is is the value of the owner.id on my repositories.

{
  viewer {
    id	
    }
}

It would be a great addition to the documentation to explain how to get this kind of value and also who to do some basic use cases (like create a repository).


#3

:wave: @dakt,

I think @arno-di-loreto is correct in that you may be omitting a required piece of input in the mutation, which is causing the query to fail (with an admittedly unhelpful error message). I’ve added an internal issue to try and clean that up so that it’s easier to parse in the future.

@arno-di-loreto, the ownerId in the createProject mutation refers to the owner of the project, which can be either a repository or an organization. creator, however, is the person who created the project, and is automatically set.

Both @dakt & @arno-di-loreto, here’s the mutation query that we’re using to power the create-an-org-project and create-a-repo-project REST API endpoints:

mutation ($ownerId: ID!, $name: String!, $body: String, $clientMutationId: String!) {
  createProject(input: {ownerId: $ownerId, name: $name, body: $body, clientMutationId: $clientMutationId}) {
    project {
      databaseId
      name
      owner {
        ... on Repository {
          name
          owner {
            login
          }
        }
        ... on Organization {
          login
        }
      }
      body
      number
      creator {
        login
        databaseId
        avatarURL
        isSiteAdmin
      }
      createdAt
      updatedAt
    }
  }
}

And here is a set of valid inputs that I’ve just used to test out the mutation:

{
  "ownerId": "MDEyOk9yZ2FuaXphdGlvbjE3MDg1NjA0",
  "name": "brooks-projects-test", 
  "body": "Test Project from GraphQL mutation",
  "clientMutationId": "1234"
}

And a sample return value:

{
  "data": {
    "createProject": {
      "project": {
        "databaseId": 246962,
        "name": "brooks-projects-test",
        "owner": {
          "login": "evil-bswinnertons"
        },
        "body": "Test Project from GraphQL mutation",
        "number": 1,
        "creator": {
          "login": "bswinnerton",
          "databaseId": 934497,
          "avatarURL": "https://avatars2.githubusercontent.com/u/934497?v=3",
          "isSiteAdmin": true
        },
        "createdAt": "2016-12-12T16:45:14Z",
        "updatedAt": "2016-12-12T16:45:14Z"
      }
    }
  }
}

You can modify this query as you see fit to get back whatever you may need (with a repository or organization that you have the apporpriate permissions to as the ownerId).

I hope this helps!
Brooks


#4

Hi there,

Any updates? I still could not resolve this issue of createProject mutation :frowning:


#5

Having the same issue here – I have obtained ownerId from

{viewer {id}}

and am passing as ownerId in the input object of createProject and getting:

“Could not resolve to a node with the global id of”

Is there a different id we need to use, or does my api key need to be assigned additional scopes?