Open omikulcik opened 1 year ago
is the graphql interface meant to be update for filtering and searching, but one basic (without filtering and searching) already exist?
Yes, I assume the graphql interface without filtering and searching is created by Strapi by default
Hi guys, We would like to take over this issue and create a PR to it - could you guide us to the right direction/ better describe the expected result and implementation basics so that we can start with it ?
Hi, I am wanting to use GraphQL and I have added my own resolver but how do I use this plugin to handle the actual search and return the data to my resolver. I know I can use raw Query but is there already a way that this plugin provides ?
register({ strapi }) {
const extensionService = strapi.service("plugin::graphql.extension");
extensionService.use(({ strapi }) => ({
typeDefs: `
type Query {
getNearbyRestaurants(lat: Float!, lng: Float!, range: Float!): [Restaurant]
}
`,
resolvers: {
Query: {
getNearbyRestaurants: {
resolve: async (parent, args, context) => {
console.log(args);
return []; // here
},
},
},
},
resolversConfig: {
"Query.getNearbyRestaurants": {
auth: false,
},
},
}));
},
If anyone needs raw query this is how it can be done
register({ strapi }) {
const extensionService = strapi.service("plugin::graphql.extension");
extensionService.use(({ strapi }) => ({
typeDefs: `
type Query {
getNearbyRestaurants(lat: Float!, lng: Float!, range: Float!): [Restaurant]
}
`,
resolvers: {
Query: {
getNearbyRestaurants: {
resolve: async (parent, args, context) => {
const { lat, lng, range } = args;
const restaurants = await strapi.db.connection.raw(
`SELECT * FROM restaurants r WHERE
ST_DWithin(
r.location_geom::geography,
ST_SetSRID(ST_MakePoint(?, ?), 4326),
?
)
`,
[lng, lat, range]
);
return restaurants.rows;
},
},
},
},
resolversConfig: {
"Query.getNearbyRestaurants": {
auth: false,
},
},
}));
},
Feature request - GraphQL support
A GraphQL interface will be developed to grant access to the filtering and searching API.