Skip to main content
Solved

Is there any library available for graphQL validation in python?


type Relationship @edge @view(space: "space-name", version: "1_1"){
    relationName: String!,
    relationType: RelationType,
    startTime: Timestamp,
    endTime: Timestamp
}

 

is there any library developed by cognite which will validate above kind of graphQL syntax also is it possible to check the values provided in graphQL ?

Best answer by AndersM

Hi Lokesh,

Have you had a look at https://github.com/graphql-python/gql - specifically its validation functionality (documented at https://gql.readthedocs.io/en/latest/usage/validation.html ) which can be performed by using introspection of the  schema from the CDF GraphQL endpoint.

Note that even if this library performs validation against the GraphQL schema there may be other issues with the schema that prevent its deployment, such as limits on schema complexity or conflicts with reserved names (https://docs.cognite.com/cdf/dm/dm_reference/dm_limits_and_restrictions/) or more subtle issues that are discovered by the data modelling service such as indexes being incompatible with the data type they are applied to.

Hope this helps, best regards,

-AndersM

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img
  • Seasoned Practitioner
  • 23 replies
  • July 1, 2024

Hi @Lnemade 

 

Thanks for reaching out!

When your are editing your data model in the Fusion UI the editor is validating that your input is valid GraphQL. Only when the definition is valid the data model can be published. When hitting the publish button the schema is applied this step will either go through successfully or be aborted with an error message explaining why the schema could not be applied.

 

There is no ongoing development of a library that will run validation externally, altough there have discussions around offering a form of dry-run functionality to have a non-comitting validation.

 

You might already have explored the option of building the schema through the rest api directly, allowing you to handle containers and views more explicitly. Depending on use-case this might be an option as well.

 

Regards,

 

Arild Eide

 


  • Author
  • Active
  • 2 replies
  • July 1, 2024

Hii @Arild Eide  , thanks for the quick response.

Actually we are not populating the model using cognite UI. We have written python script (using cognite sdk) to publish the model. Hence, we are looking for the library using which we can validate our graphQlL .

@Aditya Kotiyal @Arild Eide  Do we have any future plan for external library for validation of graphQL request,

If yes, then please let us know.

Regards,

Lokesh Nemade


AndersM
Seasoned Practitioner
  • Seasoned Practitioner
  • 26 replies
  • Answer
  • July 1, 2024

Hi Lokesh,

Have you had a look at https://github.com/graphql-python/gql - specifically its validation functionality (documented at https://gql.readthedocs.io/en/latest/usage/validation.html ) which can be performed by using introspection of the  schema from the CDF GraphQL endpoint.

Note that even if this library performs validation against the GraphQL schema there may be other issues with the schema that prevent its deployment, such as limits on schema complexity or conflicts with reserved names (https://docs.cognite.com/cdf/dm/dm_reference/dm_limits_and_restrictions/) or more subtle issues that are discovered by the data modelling service such as indexes being incompatible with the data type they are applied to.

Hope this helps, best regards,

-AndersM


Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2

Hi @Lnemade,

We are following up to see whether you're satisfied with the responses you've received?


Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2
  • Seasoned Practitioner
  • 670 replies
  • August 30, 2024

Hi @Lnemade,

I hope the issue has been resolved. I'm closing this topic for now. Please feel free to start a new post if you have any questions. 


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings