Skip to content

Create a client library #28

@braposo

Description

@braposo

This project at the moment is focused on providing a GraphQL service that connects to the Figma API and allows clients to query it through the GraphQL API.

However, I've been thinking lately that we're not doing much more than getting the API response, parsing it and returning the information required in the GraphQL query.

So maybe we could actually use something like graphql-anywhere and build a client-side library that provides a GraphQL interface to the Figma API.

I imagine something like:

import FigmaGQL from "figma-graphql";

const queryFigma = FigmaGQL.connect({
	personalAccessToken: token
});

const fileNameQuery = gql`
	{
	    file(id: "cLp23bR627jcuNSoBGkhL04E") {
	        name
	    }
	}
`;

const result = queryFigma(fileNameQuery);
/*
{
	"file": {
      	"name": "figma-graphql test file"
    }
}
*/

This would allow people to easily start querying the Figma API with GraphQL without having to worry about running the server.

For those that want more power and the benefits of a proper GraphQL implementation there would be a figma-graphql-server repository with this version of the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions