I have slices and in one of them I placed Group in the Repeatable zone and Link field inside the Group.
When I use Link field as a Content Relation and query it like this:
body {
... on MySlice {
fields {
link_field {
_linkType
__typename
... on _Document {
_meta {
type
uid
}
}
... on _ExternalLink {
url
}
}
}
}
}
In the WebGraphQL I get _meta field of the _Document, which proves that the Prismic api is working correctly, but when I call api, with the same query, from the server I don't get _meta.
ExternalLink works fine.
I am using Apollo Client.
Please let me know if you need any additional information.
So this is what I ended up doing. I am not sure if this is a workaround or the way it should be.
I used to pass empty array [] to the type property of the IntrospectionFragmentMatcher, but now I’m passing actual schema.
I queried schema like this in the Prismic WebGraphql:
query {
__schema {
queryType {
name
}
types {
kind
name
possibleTypes {
name
fields {
name
type {
kind
fields {
name
type {
kind
}
}
}
}
}
interfaces {
name
}
fields {
name
type {
kind
name
}
}
}
}
}
Maybe this is too much data, but I haven’t had time to play around with it, it just works.
When I got the result “data” field was the root property, that’s not going to work so I made __schema to be the root property, like this:
I imported this file where I initialize IntrospectionFragmentMatcher add used .json schema file like this:
import {
InMemoryCache,
IntrospectionFragmentMatcher
} from "apollo-cache-inmemory";
const introspectionSchema = require('./schema.json')
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData: introspectionSchema
});
export default function createClient() {
return new ApolloClient({
link: ApolloLink, // This part you probably already have.
cache: new InMemoryCache({ fragmentMatcher })
});
}
That’s basically it.
I got the schema, saved it into .json file, passed this .json file to IntrospectionFragmentMatcher.
Hardcoding this might not be a good idea, but how you get the schema is up to you.
Here is a useful link:
P.S. Can somebody suggest an alternative, easier way of doing this?