I have been following this link to do an apollo client version upgrade: https://www.apollographql.com/docs/kotlin/migration/3.0/
After completing the section to replace customTypeMapping I am now seeing the following error:
Apollo: unknown custom scalar(s) in customScalarsMapping: Date,Currency,Year,Month,Percentage,MediaType,Base64
My build.gradle.kts file has been updated to contain the updated custom scalar mapping methods:
mapScalar("Date", "java.time.LocalDate")
mapScalar("Currency", "java.util.Currency")
mapScalar("Year", "java.time.Year")
mapScalar("Month", "java.time.Month")
mapScalar("Percentage", "kotlin.String")
mapScalar("MediaType", "kotlin.String")
mapScalar("Base64", "kotlin.String")
mapScalar("JSON", "kotlin.String")
I don't see any mention of this being an issue anywhere else. Why am I getting this error, and how can I get my custom mappings to work like before?
Related
I’m new to Strapi and to GraphQL.
I successfully created a website that uses Apollo to query data from my Strapi website.
So functionally I have everything I need.
For my DX I’m wondering:
Since I installed the GraphQL IntelliJ plugin: Where do I find the schemas for it? I read something about remote schema detection - is that supported with Strapi GraphQL Plugin? Where can I read about it? Otherwise how can I export GraphQL schema files from Strapi?
If I got 1) to work: Will TypeScript types work out of the box? Would I use one of the GraphQL schema to TS converters out there? It feels like there might be something working automatically, but I can’t tell till I get 1) to work.
First, you asked two separate questions and should therefore separate then in two separate threads.
To answer your first question: Here is how you can utilise the GraphQL IntelliJ plugin:
You need to create a .graphlconfig file. In Webstorm select your project folder and go to 'File' -> 'New' -> 'GraphQl Configuration File'.
Change the endpoint url to your strapi endpoint.
Visit the GraphQl Tool Window, double click your endpoint and select 'Get GraphQl Schema from Endpoint (introspection)'. This will retrieve the schema file from strapi and save it to schema.graphql.
Now you can run queries against your endpoint, e.g. create a new Scratch File scratch.graphql and run queries against your endpoint or try to figure out how to solve your second question ;)
Thank you for the answer! This was helpful!
Further to this, one query - typically, is .graphlconfig committed to git repo and scratch.graphql ignored from the git repo?
In addition for others looking for a similar solution - you could use values from .env. using the format below:
{
"name": "Strapi GraphQL Schema",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "${env:GRAPHQL_HOST}/graphql",
"headers": {
"Authorization": "Bearer ${env:GRAPHQL_TOKEN}",
"user-agent": "JS GraphQL"
},
"introspect": false
}
}
}
}
I'm using Graphene package in my Flask app (https://github.com/graphql-python/graphene) and graphene-file-upload (https://pypi.org/project/graphene-file-upload/). I need to receive a file through a mutation as bellow:
class Picture(graphene.Mutation):
class Arguments:
file = Upload(required=True)
numerical_id = graphene.Int()
def mutate(self, info, file):
... continues
class Mutations(graphene.ObjectType):
picture = Picture.Field()
But when I send the mutation via an Apollo client (https://www.apollographql.com/docs/react/) I'm receving this errors:
Unknown type "Upload". Perhaps you meant "Float"?
Cannot query field "picture" on type "Mutations".
Is there any workaround for it? Thank you in advance !
Did you import Upload from graphene_file_upload.scalars? You also need to make sure you fix the view function you hook up to your /graphql view
I spent a couple of hours trying to figure this out since the mutation worked fine via Postman but not when sent from the Frontend.
The problem was that the parent component was using a different ApolloProvider from the one I was expecting.
with apollo 1.9.2 I'm used to make introspection of the graphql schema using a file as endpoint (that way the server does not need to run).
Here the 1.9 command:
apollo schema:download --endpoint ./schema/def/app.graphql ./schema/lib/schema.json
then thanks to the generated json file I can generate the types that will be used in the client and server code:
apollo codegen:generate --queries ./schema/*.graphql --schema ./schema/lib/schema.json
Now with apollo 2, the apollo schema:download command, renamed apollo service:download, supports only an url. If I do not have that types the server can not start. chicken & eggs issue.
I did not find in the doc how to do that now.
thanks for your help.
I got the answer on gitHub
I must use a config file apollo.config.js with the following
module.exports = {
service: {
localSchemaFile: './path/to/schema.graphql',
},
};
then call
apollo service:download -c ./path/to/apollo.config.js ./schema/lib/schema.json
I have a rest service which returns a json response. I need to validate response against my predefined json schema using groovy script. All the options I have found on the net describe validating json response using groovy.json.JsonSlurper against some pre conditions not the schema. So I am kinda confused where to start from. But I roughly know that I need the following steps get done.
Define custom json schema
Importing some json validator library
And validate response against schema in groovy
I'd be highly grateful if anybody helps out on the steps 2 and 3.
For your notice, I am using Soap ui tool and here is my custom schema:
{
"$schema": "http://json-schema.org/schema#",
"type":"array",
"items":{
"type": "string"
}
}
Loading libraries in Groovy depends on the tool. In SoapUI-5.6.0 the standard way is to put jar files in (from SoapUI base installation path):
On Mac: bin/ext
On Linux & Windows: lib
Validation differs depending on the library. For example with groovy-json-schema:
def json = new JsonSlurper().parseText('{"an": "example"}')
use(JsonSchema) {
json.schema = 'file://path/to/your/json/schema.json'
json.conformsSchema()
}
I Just installed ELMAH 1.2.2 from nuget to my WebApi 2 (5.2.3) project. It logs errors but elmah.axd's stylesheet doesn't load. And WebApi shows the following error:
{
"message": "No HTTP resource was found that matches the request URI 'http://api.sample.dev/elmah.axd/stylesheet'.",
"messageDetail": "No type was found that matches the controller named 'elmah.axd'."
}
I read some answers but doesn't seems related to my case.
I solved this error by preventing the WebApi's routing from catching requests to *.axd.
You can add the following line to your routing config.
httpConfig.Routes.IgnoreRoute("DynamicResources", "{resource}.axd/{*pathInfo}");
Now you can access elmah.axd's stylesheet and have a well styled log report page.