Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 4

GraphQL fragments ?

Solved! Go to Solution.

Just wondering there is an expectation that fragments will be implemented?

 

I couldn't find mention of them anywhere, or in the graphql-client gem...

3 Replies
Solution
Community Manager
Message 2 of 4

Re: GraphQL fragments ?

I ran this query just now:

 

query {
  repository(owner: "wojtekmaj" name:"react-date-picker"){
    object(oid:"50e933af2f28ca8da451c63afcced8dca467f2c7"){
      ...fields
    }
  }
}

fragment fields on Commit {
  oid
  changedFiles
  commitResourcePath
  commitUrl
  message
  resourcePath
  url
  tree{
    entries{
      name
    }
  }  
}

And the fragment seemed to work. What is it about fragments that isn't working for you?

Copilot Lvl 3
Message 3 of 4

Re: GraphQL fragments ?

Apologies, my bad.

 

I was looking here and there (ref material and code) and thought fragments were similar to variables, in that they were added to the json hash with a key of fragments.  As you've shown, they are a part of the query value...

Community Manager
Message 4 of 4

Re: GraphQL fragments ?

No apologies necessary. I'm learning this as I go too 😀