What is the best way to test GraphQL schema with Jest - testing

I wonder what is the best way to test our GraphQL schema using Jest?
As of now, we are using https://www.npmjs.com/package/#graphql-eslint/eslint-plugin but we want to integrate the types checking no-unreachable-types and other rules into our Jest tests.
For now, we have a single schema.graphql file where all definitions reside.
I've been looking at https://www.graphql-tools.com/docs but couldn't find out how to do that.
For now we don't want to test the API, just to check if the schema file is valid.

Related

How do I parse string FQL to a query using faunadb-js?

Let's say I have a string like const fql = "CreateCollection({ name: "users" })". How do I turn it into a faunadb Expr in JS?
You landed on the correct answer yourself. FQL is not a string-based language. This approach avoids problems like SQL injection, but it does mean you need to compose queries somewhere using a driver, the console, or a tool like Fauna Schema Migrate (FSM).
const fql = "CreateCollection({ name: "users" })"
The example you give leans toward schema/resource management. If that's your actual need here, consider FSM or the Fauna Serverless Framework plugin.
If you're building a front-end app using JavaScript, FSM is probably the right approach as it drops right into your app. It might also give you some more hints at how to transform strings into FQL. You would do the above in a single FQL file, e.g., fauna/resources/collections/users.fql as:
CreateCollection({ name: "users" })
If you're doing infrastructure as code in a separate pipeline or are already building with the Serverless Framework, the plugin might be a better fit.
If you want to see something else like a Pulumi or Terraform provider plugins, please submit a feature request in the forums!
The only way to do this at the moment seems to be evaluating the FQL as JavaScript.
The fauna-shell eval command is implemented using esprima to parse the FQL as ECMAScript, then running it through node's vm api with escodegen.
It's likely easier to just rewrite FQL files as JS files if you have the option!

How to reuse some steps from one yaml to another in Opentest

Lets suppose we have 2 yaml for android app containing:
Login
Performing some operation after Login
I want to reuse the Login yaml in yaml 2 , is it possible to achieve this in opentest somehow.
The proper way to reuse the same logic in multiple tests is to create a macro action and call that macro in all the tests that need to run that logic. For more information on creating and using macros, please see the OpenTest documentation.

Refference JSON schema from "define" API YAML file in Postman instead of creating a variable with actual JSON

I have an API in Postman that has defined JSON schemas for every request\response.
I also have a collection of tests that i use for testing this API.
But I don't know how to connect these two substances(things)
I have been searching for a solution for quite a while now and havent found an example set-up or a tutorial how? instead of creating a variable with actual schema in my test collection, I want to reuse already existing schema from API by $ref or some other link method.
This is my first question here, writing it just cause i haven't found a proper answer but functionality that i seek sounds really basic and logical.
Update from Valentin Despa:
"Please note that the API definition is written in a specification like Open API (or similar). It is not the same as the JSON schema which refers to the response body only."
So we can't validate response using that schema.

karate api test: how to store all responses of a feature file in an array [duplicate]

Using Karate i am making API calls sequentially. I need to store API request and response for this sequential flow of APIs in separate text files for each API call.
Need to understand how can i achieve this.
I have tried logback which stores entire execution logs in a text file.
Take a look at karate.prevRequest which will give you the "request". Now use some custom Java (or JS) code and write whatever you want to a file.
I think personally it is un-necessary because Karate's HTML report has all that you need. If someone is asking you to do this, please try convince that person that this exercise is a waste of time.

ecommerce using stripes

We have planned to start an e commerce project using Stripes + Hibernate.
Please let me know if it is good to have admin & user part in same project or two separate ones.
If it is a single project , how do i separate admin side code & user code.
for eg: if i have admin actions in com.ecommerce.adminactions pacakge and user actions in com.ecommerce.useractions package should i use dynamicmappingfilter to direct admin request to com.ecommerce.adminactions and user request to com.ecommerce.useractions ?
-http://myecommerce.com/admin/* - > should always go to com.ecommerce.adminactions
-http://myecommerce.com/ -> should go to com.ecommerce.useractions
or
Should i use #urlbinding(/admin/st.action) in each class (Hard code).
The requirement is they need multistore concept.
Please let me know your thoughts on this.Your thoughts & suggestions will be helpful
Thanks
The Stripes framework does not really influence decisions on how you should organize you're project, or how you should organize your IDE project structure, or even Java package structure or URL structure.
One or more project
Unless you have many developers, keep it all in a single project.
Package structure
A package structure should organize you're Java classes so that you put classes that are logically related (as defined by your architecture!) is in the same package. For example: com.ecommerce.action.admin and com.ecommerce.action.. See also: Properly package your Java classes
URL structure
Typically you want you're URL structure to reflect the logical structure of your website (not the same as your technical structure). To accomplish this, you should not rely on the default URL's but use #UrlBinding. With the annotation you do not hard code links, as all generated links will automatically use the UrlBinding pattern.
Multi store concept
For a multi store concept, you will need to build logic in your application for distinguishing between the different shops. For example by adding a shop id to your URL parameters. Or more sophisticated by detecting the (sub)domain name used and map that to a shop id (You can implement this by using an interceptor).