Create a datasource plugin with backend , but the frontend query action does not call my backend api

env:
nvm use 22
refer doc link: Build a data source backend plugin | Grafana Plugin Tools

fronend datasource.ts code, using DataSourceWithBackend default query method

export class DataSource extends DataSourceWithBackend<MyQuery, MyDataSourceOptions> {
  constructor(instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>) {
    super(instanceSettings);
  }

  getDefaultQuery(_: CoreApp): Partial<MyQuery> {
    return DEFAULT_QUERY;
  }

  applyTemplateVariables(query: MyQuery, scopedVars: ScopedVars) {
    return {
      ...query,
      queryText: getTemplateSrv().replace(query.queryText, scopedVars),
    };
  }

  filterQuery(query: MyQuery): boolean {
    // if no query has been provided, prevent the query from being executed
    return !!query.queryText;
  }

backend query code

func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
	backend.Logger.Info("query data!!!") 
	// create response struct
	response := backend.NewQueryDataResponse()

	// loop over queries and execute them individually.
	for _, q := range req.Queries {
		res := d.query(ctx, req.PluginContext, q)

		// save the response in a hashmap
		// based on with RefID as identifier
		response.Responses[q.RefID] = res
	}

	return response, nil
}

plugin.json code

{
  "$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
  "type": "datasource",
  "name": "Example-Datasource",
  "id": "oma-example-datasource",
  "metrics": true,
  "backend": true,
  "executable": "gpx_example_datasource",
  "info": {
    "description": "",
    "author": {
      "name": "oma"
    },
    "keywords": ["datasource"],
    "logos": {
      "small": "img/logo.svg",
      "large": "img/logo.svg"
    },
    "links": [],
    "screenshots": [],
    "version": "%VERSION%",
    "updated": "%TODAY%"
  },
  "dependencies": {
    "grafanaDependency": ">=10.4.0",
    "plugins": []
  }
}

and i follow the guid doc to run it using docker compose up, after the server run ,i can access grafana on localhots:3000, but the datasource query action did not call my backend api, look seems it call a grafana default query api ,return a json always like this:

{
    "results": {
        "A": {
            "status": 200,
            "frames": [
                {
                    "schema": {
                        "name": "response",
                        "refId": "A",
                        "fields": [
                            {
                                "name": "time",
                                "type": "time",
                                "typeInfo": {
                                    "frame": "time.Time"
                                }
                            },
                            {
                                "name": "values",
                                "type": "number",
                                "typeInfo": {
                                    "frame": "int64"
                                }
                            }
                        ]
                    },
                    "data": {
                        "values": [
                            [
                                1743001727830,
                                1743003527830
                            ],
                            [
                                10,
                                20
                            ]
                        ]
                    }
                }
            ]
        }
    }
}

how could it call my backend query api when dashboard depend on this datasource query somthing ? thank a lot !!!

Hi @lixiuxiu

did you re-build your backend after the changes you did to the backend code? (runnning mage)

it seems grafana is indeed calling your plugin and your plugin is replying otherwise you’d see an error. so this can be that you didn’t rebuild your plugin.

Try deleting your dist folder and running mage and npm run build again.

If nothing of that helps you, share a git repository so I can take a look and point you to the right direction.

Thanks academo! I did re-build backend,but nothing changed. Now i find another way which is to using docker run image directly instead of using its origin docker compose tool to run my plugin, It works!