Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of unofficial Figma GraphQL API #5

Open
fabe opened this issue Apr 16, 2018 · 1 comment
Open

Make use of unofficial Figma GraphQL API #5

fabe opened this issue Apr 16, 2018 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fabe
Copy link
Owner

fabe commented Apr 16, 2018

Might save some time in the future regarding querying and types.

https://github.com/braposo/figma-graphql

@fabe fabe added the help wanted Extra attention is needed label Apr 16, 2018
@fabe fabe added the enhancement New feature or request label Sep 19, 2018
@brandonwkipp
Copy link
Contributor

I've been looking into this for a while and haven't found a straightforward way to extract the types out of that library. It looks like there is some discussion about doing exactly that, but hasn't moved in a quite a while.

I bring this up because I've discovered a bug concerning type definitions. After fetching Figma data, I've found that if the first result of a color fields r, g, b, or a properties are either white (a value of 1) or black (a value of 0), Gatsby's graphql resolver backend ends up treating that field as an Int where it should be considered a Float. I made a simple fix for this by abstracting out the type definitions and adding a FigmaCOLOR type explicitly defining the rgba values as Float.

I can make a simple PR to help fix this bug, but it seems like a slippery slope into defining the entire Figma schema. What are your thoughts about this @fabe? For reference, I've attached the output of the error described below:

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Int cannot represent non-integer value: 0.6274510025978088

   3 |     frames {
   4 |       absoluteBoundingBox {
   5 |         height
   6 |         width
   7 |       }
   8 |       cornerRadius
   9 |       fills {
  10 |         color {
  11 |           r
  12 |           g
> 13 |           b
     |           ^
  14 |         }
  15 |       }
  16 |     }
  17 |     texts {
  18 |       fills {
  19 |         color {
  20 |           r
  21 |           g
  22 |           b
  23 |         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants