Graphql endpoint for codegen

Hi
I see monday.com has it’s api schema shared at https://api.monday.com/v2/get_schema.
But this only shares a JSON representation of the api.

I however am trying to run graphql codegen to generate a typescript ready file.
So I need the url to the actual graphql schema endpoint.
As can be seen used in the following link Home – GraphQL Code Generator.

Can anyone direct me where I can find that please?

Hello @tufvessonr and welcome to the community!

I hope you like it here :muscle:

I am not sure about this one but I will check with our team and let you know when I get a reply!

Cheers,
Matias

Hello again @tufvessonr!

I have checked with our team and we do not provide other representations for the schema.

In this case you would have to convert it to the desired representation on your end.

Cheers,
Matias

I see.

Well that’s to bad.
But thanks for the info @Matias.Monday.

Has anyone suggested to them to add that functionality?
It’s not a security risk issue and the JSON version is already shared.
So I don’t see why they would have an issue with allowing the public access to it.

Benefit wise…
It would make adding typescript to the auto generated integration apis much easier for developers.

Hello there @tufvessonr!

Nobody had suggested this as far as I know but I will share this with our team :slightly_smiling_face:

Thank you for the feedback!

Cheers,
Matias

Hi @tufvessonr ,

I had the same problem, but u can easily convert the json schema into .graphql schema:

const { readFileSync } = require('fs');
const  graphql = require('graphql');

var data = JSON.parse(readFileSync("./schema.json").toString()).data
var schema = graphql.buildClientSchema(data)

console.log(graphql.printSchema(schema));

Hello @halbritter!

Welcome to the community and thank you for sharing that :slightly_smiling_face:

I’m assuming no one’s asking about this feature because they saw the answer on this thread which makes it look like Monday.com isn’t gonna add this functionality.

Even I was debating going through the hassle of creating an account just to ask this question and potentially get zero resolution on it.

90% of people using Monday.com’s GraphQL API will want TypeScript types, and the GraphQL Codegen library is the most-common way to get those types.

I spent quite a long time searching around trying to figure out how to get this working before stumbling on this thread where it looks like Monday.com doesn’t wanna bother providing a simpler endpoint.

If I’m going to have to parse the schema myself and convert it to a different format, then that means I have to use GraphQL Codegen in a way it wasn’t intended.

Is it possible this one endpoint could be added, so it’ll be easier to use Monday.com’s GraphQL API with proper type safety?

Another issue, graphql.buildClientSchema doesn’t even exist in the latest version of the library. Now I have to waste more time trying to figure this out when it could be more-simply provided by the API authors.

This is the correct import:

import { buildClientSchema } from 'graphql/utilities'

But the error I received was:

Error: Invalid or incomplete introspection result. Ensure that you are passing “data” property of introspection response and no “errors” was returned alongside: { data: { __schema: [Object] } }.

And this is what’s in the data returns from that get_schema JSON fetch:

{
  data: {
    __schema: {
      queryType: [Object],
      mutationType: [Object],
      subscriptionType: null,
      types: [Array],
      directives: [Array]
    }
  }
}

The proper way to handle this is to call buildClientSchema(data) where data is the jsonResponse.data property:

fetch( 
 'https://api.monday.com/v2/get_schema'
)
.then((
  response,
) => (
  response
  .json()
))
.then(({
  data
}) => (
  buildClientSchema(
    data
  )
))
.then((
  graphQlSchema
) => (
  printSchema(
    graphQlSchema
  )
))

You can also return a promise from your Codegen config. That’s not documented in any of the tutorials I saw, but it worked fine.

Hopefully that helps anyone stuck on this issue.

Hello there @Sawtaytoes,

Thank you for sharing your feedback!

A request has been created for our team to add this endpoint. No ETAs at the moment.

I have shared your comments on graphql.buildClientSchema with the team as well so they can take a look :grin:

Cheers,
Matias