I'd like to include an embedded graphql processor in my .net app.
I want to execute GraphQL functions via a method and I don't need the server or an endpoint.
Basically an internal GraphQL processor. I'll define the resolvers and the schema and then run queries via a method call. Is this possible?
You may take a look NReco.GraphQL (which is based on GraphQL.Net but has an additional features, like aggregation, filter, ect.). You can compose in code schema, query (or query object) and call it just in-code.
Related
First of all, if I should ask this question elsewhere please let me know, as I'm not sure where it belongs.
I have a working application with NextJS and MSW, where I can capture the server-side API requests with MSW and return mocked JSON results.
The issue I have is that there are probably about 15 API calls that I need to mock in order to test my application properly
While I could just call each one of these manually, copy and paste the results into a file and then just return that data from the file when I capture the API call, this not a very scalable solution, especially if the back-end API changes.
Question: What are your best methods for automating the generation of these results?
In the past I have created JSON files that have all of the URL paths and query parameters explicitely listed, and I would parse through this file and query every endpoint, and then I had template files which would be used to re-populate my fixtures directory with all of the mocked responses, however this was also very cumbersome.
(For reference, the API has a somewhat similar structure to this one: https://api.gouv.fr/documentation/api-geo, where there are multiple endpoints for fetching data, and each endpoint supports a number of different query parameters to tweak the call.)
I have problems deciding on how the OrmLiteConnectionFactory should be passed to the different classes. Should it be done by injecting the container into the constructors? It is a message based design if that matters.
Basically you'd just want to pass a "reference" to what connection you'd want your Service to be executed with.
ServiceStack's Multitenancy docs shows different approaches of specifying the DB connection to use per Request DTO message, including using a custom filter, or utilizing the built-in [ConnectionInfo] or [NamedConnection] attributes.
Or if you prefer you can resolve which DB connection you want to use with your Services logic by resolving it from a IDbConnectionFactory dependency.
I am using inbuilt rest end point in Marklogic that allow me to call modules in stored in module database in Marklogic.
http://localhost:8000/LATEST/invoke?data-urlencode=module=/modules/module.xqy&database=databasename&data-urlencode=vars='{"word1":"hello","word2":"world"}'
Does it also provide any option to call direct function present within lib module?
Using vars option it allows us to pass external parameter to the invoking modules. It seems that vars option only allow to pass primitive values to external parameter to invoking module.
But how we can use this vars option to pass XML data to invoking module so that it can be access through external variable defined within module.
Any suggestion would be appreciated.
Note : I am using postman for testing of rest API.
Many thanks.
Since your goal is to get to a library function, consider creating a REST extension instead of using /invoke with a main module. A REST extension can implement your choice of HTTP verbs and accept input in whatever for you'd like. The extension can then convert those inputs to function parameters and call the function.
For more information about REST extensions, see Extending the REST API, which includes an example XQuery extension.
Is it possible to use the parameters incoming from the webservice ( named 'Query' in my case ), in the SQL in the reader module.
I think it's possible, but I cannot find anywhere how to template these properties in the SQL query so that it becomes dynamic.
Currently, you'd have to implement the logic for inserting the query key in the client application that calls the web service. Support for parameterized SQL queries is in our feature backlog.
Yes you can. Here is the blog demonstrating "how-to" for web service parameters - http://blogs.technet.com/b/machinelearning/archive/2014/11/25/azureml-web-service-parameters.aspx
I am already using the standard WebAPI and returning JSON objects to my client. Now I saw an application that returned OData.
Can someone explain if there is any reason for me to use OData if I do not want to query my data from anything other than my own client running in the browser. Are there advantages that I could get through using OData ?
If you are only using your data in your own browser application, there is only few advantages to use OData in your situation:
OData is able to provide metadata about your service interface that can be used to generate client code to access the service. So if you have lots of client classes that you need to create, this could speed up your process. On the other hand, if you can share your classes between the server and an ASP.NET based client or if you only have a few classes, this might not be relevant in your situation.
Another - bigger - advantage in your situation is the support for generic queries against the service data. OData supports IQueryable so that you can decide on the client side on how to filter the data that the service provides. So you do not have to implement various actions or use query parameters to provide filtered data. This also means that if you need a new filter for your client, it is very likely that you do not have to change the server and can just put up the query on the client side. Possible filters include $filter expressions to filter the data, but also operations like $skip and $top that are useful when paging data. For details on OData and queries, see this link.
For a complete overview about OData and Web API see this link.
Here are few advantages of OData.
OData is a open protocol started by Microsoft is based on Rest Services so we can get data base on URL.
It suppport various protocol like http,atom,pub and also support JSON format.
No need to create proxy classes which we used to do it in web service.
You will able to write your own custom methods.
It is very light weight so the interaction between client and server will be fast compared to web service and other technologies.
Very simple to use.
Here are few reference links.
http://sandippatilprogrammer.wordpress.com/2013/12/03/what-is-odata-advantages-and-disadvantages/
http://geekswithblogs.net/venknar/archive/2010/07/08/introduction-odata.aspx
http://www.zdnet.com/blog/microsoft/why-microsofts-open-data-protocol-matters/12700
I agree with the answers already posted, but as an additional insight...
You mentioned that:
... if I do not want to query my data from anything other than my own
client running in the browser...
You may not wish to run it normally through anything but your own cilent, but using oData you could use other querying tools for debugging. For example LinqPad allows you to use oData endpoints (such as that provided by stackoverflow).
It's probably not a good enough reason to implement oData if you don't have another reason to do so, but it's an added bonus.